What’s the difference between invoking the function using func.apply(); and func.call();
As you can read from the answers, the main difference is that apply lets you invoke the function with arguments as an array, whereas call requires the parameters to be listed explicitly.
And that got me thinking. Given all of the things that designers and developers are expected to know, which other mnemonics (techniques to aid the retention of information) do we use?
For example, I remember the order in which to apply CSS margin or padding shorthand properties, as being the same as the points of a compass: N (top), E (right), S (bottom), W (left).
I actually avoided the 3-value margins and paddings because I didn’t have any useful way to memorize them so I always wrote 4 values instead. This changed after I envisioned the values going from top to bottom being represented with corners of a diamond:
I envision the successive values go from top to bottom referencing the corner/corners of a diamond on the same (imaginary) horizontal line.
And how to remember to start from the top? I imagine I go with the direction of gravity. Actually, the first value of any margin or padding, regardless whether it consists of 1, 2, 3 or 4 values, always represents the top!
For 4 values I simply imagine a clock!
Therefore, I think the people who decided on this part of CSS specs came up with the most natural and intuitive scheme
There’s also background-position, which may be tricky because it accepts two values but doesn’t follow the same rule as a 2-value margin. The first one is left offset and the second one is top offset - the other way round. For some time I thought the rules were the same but they are not. Here I have to think these are values of a 2-dimentional axis, where the convention is to first write the value on the x (horizontal) axis and then on the y (vertical) axis.
My most useful trick is Google. Why waste brain cells on minute implementation details that can be looked up in two seconds online. Perhaps not for CSS and HTML – all that stuff I have just memorized because it is so simply but for programming the signature of functions and what not can always be found really quickly. At least that has been my own experience. The best method is just to do things over and over in my book. Repetition breeds memorization.
I’m the same way. Some details I memorize just through repetition of using it every day. Other details I need to look up every time. And as long as the Internet continues to be a thing, I think that’s a perfectly fine way work.
A useful way to remember Markdown script is to save the syntax in your Private Notes Profile. After usage a few times the script becomes second nature.