JavaScript Cheat Sheet For Beginners
In this post you can find a cheat sheet for JavaScript for beginners, this cheat sheet helps you a lot in practicing or revising JavaScript. You must have some knowledge of JavaScript basics so that you can use this cheat sheet as a reference effectively.


Value Types

  • Number Any numeric value.
  • String Characters inside quote marks.
  • Boolean True or False.
  • Null Empty and meaningless.
  • Object Any value associated with the object.
  • Function Value returned by a function.

Operators

  • x+y (numeric) Adds x and y together.
  • x+y (string) Concatinates x and y together.
  • x-y Subtracts y from x.
  • x*y Multiplies x and y together.
  • x/y Divides x by y.
  • x%y Modulus: The remainder when x is divided y.
  • x++,++x Adds one to x.
  • x--,--x Subsctract one from x.
  • -x Reverses the sign on x.

Assignments

  • x=y Sets x to the value of y.
  • x+=y Same as x = x + y.
  • x-=y Same as x = x - y.
  • x*=y Same as x = y.
  • x/=y Same as x = x / y.
  • x%=y Same as x = x % y.

Adding to an Array

  • .length Adds one value to the end of an array.
  • push() Adds one or more items to the end of an array.
  • unshift() Adds one or more items to the beginning of an array.

Misc

  • parseInt() Takes a value and tries to convert it to an integer.
  • isNaN() Returns true if something is not a number.
  • setTimeout() Specify that an action should occur on a particular schedule.
  • Math.floor Rounds a number down.
  • Math.random Generates a random number between 0 and 1.
  • getElementByTagName()
  • getElementById()
  • getElementByClassName()
  • element.innterHTM returns all the HTML between the opening and closing tags.
  • element.nodeType property, returns the number of the node type.

Event Handlers

  • onabort The aborted user loading the page.
  • onblur The user left the object.
  • onchange The user changed the object.
  • onclick The user clicks an object.
  • onerror The script encountered an error.
  • onfocus The user made an object active.
  • onload The object finished loading.
  • onmouseover The cursor moved over an object.
  • onmouseout The cursor moved off an object.
  • onselect The user selects the contents of an object.
  • onsubmit The user submitted a form.
  • onunload The user left the page.
  • onmove The window is moved.
  • ondblclick A double click of a mouse button.
  • onclick A single click (down and then up) of a mouse button.
  • onreset A reset button is clicked on a form.
  • onkeydown Triggered when a key is pressed down.
  • onkeyup Triggered when a key is released.
  • onkeypress Triggered when a key is pressed and then released.

Comparisons

  • x==y Returns true if x and y are equal.
  • x===y Returns true if x and y are identical.
  • x!=y Returns true if x and y are not equal.
  • x!==y Returns true if x and y are not identical.
  • x>y Returns true if x is greater than y.
  • x>=y Returns true if x is greater than or equal to y.
  • x<y Returns true if x is less than y.
  • x<=y RetJrns true if x is less than or equal to y.
  • x&&y Returns true if both x and y are true.
  • x||y Returns true if either x or y is true.
  • !x RetJrns true if x is false.

Remove Item From an Array

  • pop() Removes the last item from the array.
  • shift() Removes the first item from the array.

📝📝 Again this is not a complete JavaScript overview, this is just a small cheat sheet from where you can take help for clearing concepts.

Post a Comment

Previous Post Next Post