java script cheat sheet code example
Example 1: javascript cheat sheet
Best Cheat Sheet:
https://websitesetup.org/wp-content/uploads/2020/09/Javascript-Cheat-Sheet.pdf
Example 2: java script basik cheat sheeet
var pi = Math.PI;
Math.round(4.4);
Math.round(4.5);
Math.pow(2,8);
Math.sqrt(49);
Math.abs(-3.14);
Math.ceil(3.14);
Math.floor(3.99);
Math.sin(0);
Math.cos(Math.PI);
Math.min(0, 3, -2, 2);
Math.max(0, 3, -2, 2);
Math.log(1);
Math.exp(1);
Math.random();
Math.floor(Math.random() * 5) + 1;
Example 3: dom javascript cheat sheet
var newHeading = document.createElement('h1');
var newParagraph = document.createElement('p');
var h1Text= document.createTextNode('This is a nice header text!');
var pText= document.createTextNode('This is a nice paragraph text!');
newHeading.appendChild(h1Text);
newParagraph.appendChild(pText);
Example 4: cheat sheet javascript
if ((age >= 14) && (age < 19)) {
status = "Eligible.";
} else {
status = "Not eligible.";
}
Example 5: list of javascript cheat sheet
list.splice(list.indexOf(REF)+1, 0, NEW))
Example 6: java script basik cheat sheeet
var pi = 3.141;
pi.toFixed(0);
pi.toFixed(2);
pi.toPrecision(2)
pi.valueOf();
Number(true);
Number(new Date())
parseInt("3 months");
parseFloat("3.5 days");
Number.MAX_VALUE
Number.MIN_VALUE
Number.NEGATIVE_INFINITY
Number.POSITIVE_INFINITY