[Question]
  [
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages.
Given that I play almost exclusively in JavaScript, [Japt](https://github.com/ETHproductions/japt) seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please post any tips you have for Japt in the answers below.
As I'm a beginner in Japt and golfing languages in general, if you could "translate" your tips to JavaScript, where possible, that would be a big help in helping me get to grips with things.
  
[Answer]
## Moving from JavaScript to Japt
As you may know, Japt is simply a shortened, extended version of JavaScript. I created Japt because I was tired of long property names, like `String.fromCharCode(x)` and `Math.floor(x)`, and the tediousness of doing things such as creating a range. Here's the bare minimum you need to know when going from JavaScript to Japt:
* Japt is a *transpiled* language; Japt code is *transpiled* to JavaScript and then run as JS. (I guess you could say *compiled*, but transpiled sounds more hipster. Disclaimer: I know absolutely nothing about being hipster)
* All entries are full programs by default. The input is implicitly parsed, and the first six inputs are put into the variables `U`, `V`, `W`, `X`, `Y`, and `Z`; the full array is stored in `N`. The result of the last expression is automatically printed.
* All uppercase letters are variables, and stay the same when transpiled. Most have preset values, which you can find in the "Variables" section of the Japt docs (at the [interpreter](http://ethproductions.github.io/japt)).
* All lowercase letters are prototype functions, or *methods*. Japt adds the methods `a`-`z` (and `à`-`ÿ`) on numbers, strings, and arrays. When you use one of these letters, Japt fills in the `.` and `(`; `Uc` in Japt is equivalent to `U.c(` in JavaScript, which could mean ceil, charCodeAt, or concat, depending on the type of `U`. This is where most of Japt's power comes from; you can find full lists of these methods under the "\_\_\_\_\_ functions" sections of the Japt docs (at the [interpreter](http://ethproductions.github.io/japt)).
* A space represents `)`, and `)` represents `))`. This is because when I first designed Japt, I wanted to save as many bytes as possible, and that's how I first thought of doing this. (Though `Us w n` does look better than `Us)w)n)`, IMHO.)
* A function is denoted as `ABC{...}`, where the `ABC` can be any string of variables. Functions work for the most part as they do in JS, the main difference being the last expression is automatically returned (rather than having to use `return` or fancy ES6 parentheses).
* `'` denotes a single char string (i.e. `'a` is the same as `"a"`), and `#` takes the next char-code and becomes that number (`#e` is the same as `101`).
* Anything between dollar signs `$` stays the same during the transpilation process. You can use this to implement `for` loops, for example, since Japt doesn't have those, but I would suggest using other methods (such as `m` on strings and arrays, or `o` on numbers).
* Most other chars commonly used in JS — `""`, `0-9`, `(`, `+`, `=`, etc. — stay the same when transpiled (for the most part, anyway).
And that is all you need to know to write basic Japt code. Achieving maximum golf power in Japt requires more knowledge, but that can be found in other answers.
---
Here's a basic example. Say you have want to take a string of ASCII characters and replace each with its hexadecimal char code. Here's how you might do that in JavaScript:
```
U.split("").map(x=>x.charCodeAt(0).toString(16)).join("")
```
Now to convert to Japt. `.split("")` in JS is equivalent to `q""` in Japt, or even shorter, just `q`. `.join("")` is also just `q`, the difference being that the object is an array instead of a string. `.map(` is `m`, `.charCodeAt(` is `c`, and `.toString(` is `s`. So our Japt code might look like:
```
Uq mX{Xc0 s16} q 
```
In Japt, though, `m` works as well on strings as it does on arrays, so we can remove both `q`s:
```
UmX{Xc0 s16}
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.4&code=VW1Ye1hjMCBzMTZ9&input=IkhlbGxvLCBXb3JsZCEi) As you can see in the "JS code" box, this directly transpiles to:
```
U.m(function(X){return X.c(0).s(16)})
```
As you learn to work with Japt, you'll become less and less focused on converting back and forth from JavaScript and be able to code in Japt as its own language. Here's an explanation leaving out the JavaScript portion entirely:
```
UmX{Xc0 s16}
               // Implicit: U = input string
UmX{       }   // Take U, and replace each character X with the result of this function:
    Xc0        //   Take the char-code at index 0 in X (the first and only one).
        s16    //   Convert this to a hexadecimal string.
               // Implicit: output result of last expression
```
[Answer]
# Compressing String Arrays
> 
> **UPDATE:** The tools featured in this tip have since be rewritten, improved and integrated into [my Japt interpreter](https://petershaggynoble.github.io/Japt-Interpreter/). For the best results it is recommended that you use that compressor over any of those linked below. I'll revisit this tip when I have some more time and rewrite it with the new compressor in mind.
> 
> 
> 
## Introduction
If you have an array of strings in your code, the most obvious way to compress it would be to [run each string through `Oc`](https://codegolf.stackexchange.com/a/121267/58974) individually. For the purposes of this tip, we'll be working with the array [`["lollipop","marshmallow","nougat","oreo"]`](https://ethproductions.github.io/japt/?v=1.4.5&code=WyJsb2xsaXBvcCIsIm1hcnNobWFsbG93Iiwibm91Z2F0Iiwib3JlbyJd&input=), which weighs in at 42 bytes initially. Running each string through `Oc` gives us:
[```
[`lo¥ipop`,`Ú\hÚaow`,`Í`,`eo`]
```](https://ethproductions.github.io/japt/?v=1.4.5&code=W2Bsb6VpcG9wYCxg2lxo2mFvd2AsYM0FhWAsYI5lb2Bd&input=)
That's now 33 bytes, a decent saving.
---
## Step 1
**But**, we can do better. If we join the array to a newline separated string, we can get rid of the brackets, commas, and extraneous backticks and split on newline to get our array. Applying that to our example array gives us the following:
[```
`lo¥ipop
Ú\hÚaow
Í
eo`·
```](https://ethproductions.github.io/japt/?v=1.4.5&code=YGxvpWlwb3AK2lxo2mFvdwrNBYUKjmVvYLc=&input=)
Down to 26 bytes now.
---
[Answer]
## Compressing strings
Japt (currently) uses the [shoco](http://ed-von-schleck.github.io/shoco) library for string compression. You can compress an arbitrary string using `Oc`, as long as it contains runs of lowercase letters:
```
Oc"Hello, World!"
```
[This outputs](http://ethproductions.github.io/japt/?v=1.4.4&code=T2MiSGVsbG8sIFdvcmxkISI=&input=) `HÁM, WŽld!` (well, the `Ž` is technically an unprintable character). You can decompress this by wrapping it in backticks:
```
`HÁM, WŽld!`
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.4&code=YEjBTSwgV45sZCFg&input=)
Alternatively, you can use the `Od` function to decompress an arbitrary string. This isn't usually useful, but [it has its purposes](https://codegolf.stackexchange.com/a/109518/42545)...
[Answer]
## Shortening Numbers With Char-Codes
In Japt, you can use `#`, followed by a character to create a char-code. This comes in handy when shortening longer numbers.
As @ETHproductions mentioned, this only works on three-digit runs in the range 100-255, unless you are willing to switch to UTF-8.
### Examples:
`123` can be shortened to `#{`
`101` can be shortened to `#e`
**You can even chain these together:**
`123101` can be shortened to `#{#e`
You can use `String.fromCharCode(123)` in JavaScript, or `123d` in Japt to find the appropriate character.
`String.fromCharCode(123)` returns `{`
[Answer]
# Quick tip: Empty array `[]`
Japt has a constant for an empty array: `A`. But, in order to access it, you must prepend a semicolon `;` to your programme to use Japt's alternative constants, otherwise `A` will be `10`. So using `;A` actually offers a 0 byte saving over `[]`, but *will* save you bytes if you need to assign your array to a variable (e.g., `A=[]`).
However, if (and only if) your programme is not taking any input, you can access the empty array with just 1 byte by using the `N` variable, which is the array of inputs - with no inputs, it would be empty. [Try it out here](http://ethproductions.github.io/japt/?v=1.4.4&code=Tg==&input=LVE=).
This has also has the added benefit of allowing you to use the default constant values in your programme and, in some cases, can still save you bytes over using `;A` even when your programme is taking input thanks to the shortcuts for `s1` and `s2`.
[Answer]
## Evaluating JavaScript
Japt allows you to execute raw JavaScript by wrapping it around `$...$`.
For example, `$alert("hello world")$`
This can be shortened by taking advantage of Japt's auto-closing `$` and `)`.
`$alert("hello world")$` can be shortened to `$alert("hello world"`
### Compressing JavaScript
You can also compress JavaScript using `Ox`.
If there is a JavaScript function that you want to use, say `screen.width`, you can compress the string [`"screen.width"` using `Oc`](http://ethproductions.github.io/japt/?v=1.4.4&code=T2Mic2NyZWVuLndpZHRoIg==&input=), then [inserting the result in between Ox`...`](http://ethproductions.github.io/japt/?v=1.4.4&code=T3hgc9fHbi6xZJA=&input=)
Note that you do not need closing quotes in Japt when it is not followed by anything else.
[Answer]
# Know the flags
As per [the latest meta consensus (Dec 2017)](https://codegolf.meta.stackexchange.com/a/14339/78410), command-line flags are no longer counted towards bytes. It's really a great news for Japt since it has many flags for extra treatment on input/output.
All available flags in Japt are described below, **in the order of evaluation**. The flags in the same group are exclusive to each other. Note that the flags in different groups can be used in combination, resulting in something like [this](https://codegolf.stackexchange.com/a/165894/78410) :)
## `mdefæ`
The whole program is mapped over the first argument (`U`).
If more arguments are present, they are passed as-is (i.e. *not* pairwise mapped). Otherwise, the second argument is the index, and the third is the whole array, just like `U.m`. If `U` is a number, it is converted to range; if string, it's converted to array of chars and the results are joined together.
* `-m`: Applies the above and nothing else.
* `-d`: Returns `true` if some result is truthy, `false` otherwise.
* `-e`: Returns `true` if all results are truthy, `false` otherwise.
* `-f`: Returns the array of elements of `U` whose results are truthy.
* `-æ`: Applies `-f` and returns its first element.
## `gh`
Takes an element at the specified index.
* `-g`: Takes first element (index 0).
* `-gX`: Takes the element at index `X` (can be any positive integer).
* `-h`: Takes last element.
## `!¡`
Convert the result to boolean.
* `-!`: Apply boolean not.
* `-¡`: Apply boolean not twice (returns the truthiness).
## `N`
Convert the result to number. The unary plus is used.
## `PRSQ`
Convert to string of some sort.
* `-P`: Join the array with `""`.
* `-R`: Join the array with `"\n"`.
* `-S`: Join the array with `" "`.
* `-Q`: Apply `JSON.stringify` (can be any object, not only an array). [Example](https://codegolf.stackexchange.com/a/165497/78410).
## `x`
Applies the function `x` to the output. (It's literally `x`, not "any single lowercase alphabet function".)
* Array: Sum.
* String: Trim from both ends.
* Number: Round to integer.
[Answer]
## Take advantage of preset variables
Variables `A`-`S` are preset to common values that take more than one byte to represent in Japt:
* `A`-`G` are `10`-`16`.
* `H` is `32`, `I` is `64`, `J` is `-1`, `L` is `100`.
* `K` is defined as `new Date()`, which you can manipulate in various ways.
* `M` and `O` are objects with various useful functions. You can learn more in the docs.
* `P` is the empty string, `Q` is a quote mark, `R` is a newlines, and `S` is a space.
* `T` is set to `0`, so you can use it as an accumulator if necessary.
---
If the first character in the program is a semicolon `;`, `A-L` are reset as follows:
* `A` is the empty array `[]`.
* `B` is `"ABCDEFGHIJKLMNOPQRSTUVWXYZ"`.
* `C` is `"abcdefghijklmnopqrstuvwxyz"`.
* `D` is `"QWERTYUIOP\nASDFGHJKL\nZXCVBNM"`.
* `E` is `"[a-z]"`, and `F` is `"[A-Za-z]"` (useful before I added these as regex features)
* `G` is `36`, `H` is `65`, and `I` is `91` (useful for alphabet ranges).
* `J` is a single comma; `L`, a single period.
Nowadays only `A`, `B`, `C`, and `D` from this list are really useful. I'm planning to add a better system which allows up to 256 two-byte variables, which will be preset to these values and a whole lot more.
[Answer]
## Unicode shortcuts
There are many common structures in Japt that just can't be stored in a single ASCII char, such as `qS`, `p2`, `mX{`, `}`, etc. So to get around this, Japt has "Unicode shortcuts", which are characters in the range `\xA1`-`\xDE` (`¡`-`Þ`) which expand to these common structures. You can find a full list of these in the [interpreter docs](http://ethproductions.github.io/japt).
Additionally, `@` stands for `XYZ{`, and `_` stands for `Z{Z`, to help build functions. So let's golf our example program from [another answer](https://codegolf.stackexchange.com/a/121286/42545):
```
UmX{Xc0 s16}
```
Firstly, we can replace `X{X` with `_`, which gives us:
```
Um_c0 s16}
```
Then we can replace `m_` with `®` saving another byte:
```
U®c0 s16}
```
Or we could replace `X{` with `@`, which gives us:
```
Um@Xc0 s16}
```
This then allows us to use the `¡` shortcut to save two bytes:
```
¡Xc0 s16}
```
One of these two paths can be shortened 1 byte more than the other. Can you figure out which?
[Answer]
# Use auto-functions
You most likely already know that `@` and `_` are shortcuts for `XYZ{` and `Z{Z`, respectively (covered in the [Unicode shortcuts](https://codegolf.stackexchange.com/a/121378/42545) answer). But sometimes you can make functions even shorter.
Suppose you had an array of characters and you wanted to map each character to its char-code. You could do this with either of these:
```
mX{Xc} 
m_c} 
```
But there's a better way. If a method or operator is the first item after another method or a `(`, it gets turned into a string. So these two lines are equivalent:
```
r'a'b  // Replace all "a"s with "b"s; transpiles to .r("a","b")
ra'b   // Does the same thing, 1 byte less; transpiles to the same thing
```
But how does that help with our functions? Well, most methods that accept functions, if given a string representing a method or operator, will interpret it as a function. Which means you can also do this:
```
m_c}  // Map each item to its char code
m'c   // Does the same thing, 1 byte less
mc    // Also does the same thing, 2 bytes less
```
I call these "auto-functions". There are several different varieties:
* `m@Xc}` → `mc`
* `m@Xc1}` → `mc1`
* `m@X+1}` → `m+1`
* `m@1+X}` → `m!+1`
* `m@2pX}` → `m!p2`
Hopefully you get the idea. To swap the arguments, just prefix the method or operator with `!`.
[Answer]
# Implicit Variable Assignment
Whenever you start a new line in Japt the result of the previous line is automatically assigned to one of the input variables (`U`-`Z`), with the first line being `U`, the second `V`, and so on.
Let's take an example: say you wanted to create 2 arrays to work with, one containing the numbers 1-10 and the other containing their squares. The long way to do this would be like so:
```
U=Aõ V=Um² [do something with the arrays]
```
Using automatic variable assignment, though, that can be shortened to:
```
Aõ
Um²
[do something with the arrays]
```
We've saved 4 bytes there. But, in this instance, we can save one more byte because the array of 1-10 is assigned to `U` and [`U` can be omitted in certain scenarios](https://codegolf.stackexchange.com/a/121417/58974):
```
Aõ
m²
[do something with the arrays]
```
## Caution
One thing to be careful of with this tip is that you don't overwrite any input variables you might need later on in your programme. This can be avoided by leaving one or more empty lines at the start of it. In the following example, the 2 arrays will be assigned to the variables `V` & `W`, instead of `U` & `V`:
```
Aõ
Vm²
[do something with the arrays]
```
[Answer]
# Know the Javascript
Since any Japt code runs as transpiled JS, good understanding of JS operators and built-in methods helps a lot in golfing pieces of Japt code.
### Relevant JS tips
* [Implicit casting, increment/decrement operators](https://codegolf.stackexchange.com/a/2714/78410)
* [Some arithmetic/bitwise operator recipes](https://codegolf.stackexchange.com/a/126112/78410)
	+ This doesn't necessarily save bytes in Japt (due to shortcuts), but it's always good to keep in mind how the operators work.
* [Know the comma and assignment-anywhere](https://codegolf.stackexchange.com/a/60969/78410)
	+ The comma (usually implicitly inserted in Japt) is especially useful when you want to initialize a variable and then do some work on it. The following code assigns empty array to `U` and then evaluates `V.m`. (Having a newline activates implicit assignment to `U` on the first line.)
```
[]Vm@...
...
```
* [Short-circuiting](https://codegolf.stackexchange.com/a/2788/78410)
* [Splitting with numbers](https://codegolf.stackexchange.com/a/11699/78410)
	+ This can be generalized to any method that accepts strings but not numbers. A number passed there will implicitly cast to a string, often saving a byte (e.g. `0` over `'0`).
### Relevant JS built-in functions
Closely look at what parameters are passed to function arguments.
* [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
	+ Related Japt methods: `Array.a/b/m/x/y/í`, `Number.o/õ`, `String.m/y/í`
* [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
	+ Related Japt methods: `Array.r/å`, `String.å`; for `å`, 4th argument is not passed.
* [`Array.prototype.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
	+ Related Japt method: `Array.d`
* [`Array.prototype.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
	+ Related Japt method: `Array.e`
For string methods, it's good to know how the behaviors differ between passing a string or regex with or without `g` flag.
* [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
	+ Related Japt methods: `String.f/o`
* [`String.prototype.search`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search)
	+ Related Japt method: `String.â`
* [`String.prototype.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
	+ Related Japt methods: `String.e/k/r`
	+ For `e/r`, passing functions as 2nd argument is OK, and understanding the function parameters is highly encouraged.
[Answer]
# Use multiple lines when necessary
For most not-too-hard challenges, you can express the solution in just one line of Japt, as a sequence of applying built-in functions. But more complex ones will require to use looping constructs, recursion, or reusing large chunks of code. This is where multi-line programming comes in.
## Remove closing parens
**Task**: Given an array of numbers, pair each element with the index squared, and sort it by the sum.
`[5,1,17,9,3] => [[5,0],[1,1],[17,4],[9,9],[3,16]] => [[1,1],[5,0],[9,9],[3,16],[17,4]]`
One-line solution is `íUm@Yp2})ñx`, but `})` costs two bytes (and there is no one-byte shortcut). You can remove `})` by simply moving the trailing `ñx` to the next line, so the code looks like this:
```
íUm@Yp2
ñx
```
and the transpiled JS becomes:
```
U = U.í(U.m(function(X, Y, Z) { return Y.p(2) })); U.ñ("x")
```
You can clearly see this does the same thing as the one-line solution, just assigning the intermediate result back to `U`.
## Recurse with implicit arguments
The recursion function `ß` takes all of `UVWXYZ` as implicit parameter, if not specified. `U` is obviously the main input, but you can use any of `VWXYZ` to keep track of other values you need. For example, you can do something like the following:
```
(modify input and implicit assign to U)
(modify V and implicit assign to V)
(test something and call ß without arguments; U and V are passed automatically)
```
Alternatively, if all you want is a temporary variable, you can use inline assignment, like `(T=...)`, as the variable `T` (0) is rarely used as-is.
## Reuse a long function
For this, I don't think I can come up with a good example task, so I'll reference [the only solution this tip was used](https://codegolf.stackexchange.com/a/165790/78410), and just outline some general ideas.
* In order to reuse a function, you need to store it in a variable. Starting a line with the function-opener `{`, `@` or `_` does the job. Alternatively, you can also do something like `(T=@...})` to embed the function assignment inside a more complex line.
* It's actually not trivial to call the stored function. Suppose `V` is a function and we want to call `V(U)` in JS. `VU` does not work since it simply means `V,U`. `V(U` doesn't either; it's `V,(U)`. Even the function methods aren't helpful very much. The best way we found is:
	+ `[U]xV` (map and sum) if the result is number
	+ `UmV` if `U` is a single char and `V` returns a string, or
	+ `$V($U` or `[U]mV g` in general.
* However, mapping or looping with it is rather easy. To map over an array, use `UmV`. To find the first integer that satisfies `V`, use `Va`.
[Answer]
# Fun with Auto-Functions
As a follow-up to [ETH's general tip on auto-functions](https://codegolf.stackexchange.com/a/124037/58974), this tip will provide a few specific examples of byte saving tricks you can achieve with them, which I'll add to as I think of more.
---
## Get the largest integer in an array.
Assume we have the array `[3,1,4,2]` assigned to variable `U` and we ant to retrieve the largest number from it. We *could* do it in 4 bytes by sorting the array and then popping the last element:
```
Un o
```
The downside to that is that we've modified the original array; `U` is now `[1,2,3]` which may not always be desirable. Luckily, there's a way of doing it without modifying the array that's also one byte shorter:
```
Urw
```
What we've done there is reduced the array using the `w` method, which, when used on an integer returns the larger of the integer and the method's argument (e.g., `2w5` returns `5`). So the above is the equivalent of `UrÈwY` or `UrXY{XwY}`. Note, though, that this tip won't work in the case of *all* the integers in the array being negative.
[Answer]
## When *not* to use `í`
`í` is a useful built-in that pairs (or `zip`s) two arrays or strings, and optionally maps each pair through a function. However, it currently has a few minor issues when given uneven arrays or strings:
* If the first array has more items than the second, the non-existent items in the second will be given as `undefined`.
* If the second array has more items than the first, it will stop processing at the end of the first array.
This can make it difficult to, say, compare two uneven strings and take the char with the higher code point from each pair. Even if you know that `U` is going to be the longer one, it still takes far to many bytes to solve this simple task:
```
UíUç hV @[XY]n o
```
What you could do instead would be to take input as an array of two strings, *transpose* the array with `y`, and then map each row to the correct result:
```
Uy m_q n o
```
This has the advantage of always padding the shorter string with spaces, making it a piece of cake to go through the entirety of both strings.
Real-life examples: [1](https://codegolf.stackexchange.com/a/125485/42545), [2](https://codegolf.stackexchange.com/a/138546/42545)
[Answer]
# Generate the ASCII Range
> 
> Update: Japt now has a constant for the ASCII range; the alternative value for `E`, accessible with `;`. See [this tip](https://codegolf.stackexchange.com/a/121380/58974) for more on Japt's constants.
> 
> 
> 
While Japt doesn't (yet) have a built-in for the ASCII range, you can generate an array of characters in just 5 bytes:
```
95odH
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=OTVvZEg=&input=)
---
## How It Works
`95o` creates the range `[0,95)` with each element being passed through the [auto-function](https://ethproductions.github.io/japt/?v=1.4.5&code=OTVvZEg=&input=) `d` which, when used on a number, returns the character at that codepoint. Pass a number as an argument to the `d` method, in this case `H`, the Japt constant for 32, and it will be added to the original number before being converted.
An equivalent solution in JavaScript would be:
```
[...Array(95)].map((_,x)=>String.fromCharCode(x+32))
```
---
## Random Characters
To get a random character in the ASCII range, use `ö` instead, which returns a random number from the range `[0,X)`, where `X` is the number it is run on.
```
95ö dH
```
Or, to get an array of multiple random characters, pass the number of characters you need as an argument of `ö`. The following will return 10 characters:
```
95öA mdH
```
[Answer]
## Remove unnecessary structural chars
By structural chars, I mean `{}`, `()`, `$`, even `"` and ```. You can typically remove these chars whenever they occur right at the end of a program (e.g. `UmX{Xc +"; "} -> UmX{Xc +";` ).
Additionally, you can remove parens or spaces whenever they appear in the following places:
* Up against a semicolon `;` (or the end of the program);
* To the right of `{` (and by extension, `@`) or `[`, or the left of `]` or `}`.
Also, commas are very rarely needed to separate arguments. If you write `AB`, for example, Japt knows you mean `A` and `B` separately. You only really need a comma to separate two numerical literals, such as `Us2,5`.
Finally, if there's a `U` at the start of a program or after a `{` or `;`, followed by a method call (lowercase letter or related Unicode shortcut) or any binary operator excluding `+` and `-` (`*`, `&`, `==`, etc.), you can remove the `U` to save a byte and Japt will insert it for you.
[Answer]
# Modify the Last Element in An Array
Sometimes you may need to modify the last element in an array so here's an explanation of a short way of doing that. We'll be working with the array `[2,4,8,32]` assigned to input variable `U` and dividing the last integer (`32`) by 2.
The obvious way to achieve this would be with this 9 byte solution ([Demo](http://ethproductions.github.io/japt/?v=1.4.5&code=VWgzVWczIC8y&input=WzIsNCw4LDMyXQ==)):
```
UhJUgJ /2
```
* `hnx` sets the element at index `n` to `x`.
* `gn` returns the the element at index `n`.
* `J` is the Japt constant for `-1`, which, thanks to Japt's support for negative index, allows us to work with the last element in an array; handy when you don't know the size of the array.
* And `/2` is simply division by 2.
So the above sets the element at index `-1` in the array to the element at index `-1` in the array divided by 2. Or in JavaScript: `U[3]=U[3]/2`. When you write it out like that, it seems a far too long-winded way of going about it. Luckily, there *is* a shorter way; we could pop the last element from the array, modify it and push it back to the array. Performing each of those operations individually would take more than 9 bytes but we can do them all at once for just 7 bytes, a 2 bytes saving ([Demo](http://ethproductions.github.io/japt/?v=1.4.5&code=VXBVbyAvMg==&input=WzIsNCw4LDMyXQ==))
```
UpUo /2
```
Translated to JS, it's the equivalent of:
```
U.push(U.pop()/2)&&U
```
]