Dictionary
A-Z
Name | Examples |
[...array] | var a = [1,2,3,4,5] [...a] //Equal to [1,2,3,4,5] |
`Hello ${a}` | var a = "John" //Equal to "Hello John" |
abs() | Math.abs(-1.234) |
add() | var unique = new Set([1,2,3,4,5]) |
alert() | alert("happy new year") |
acos() | Math.acos(0.4) //Equal to 1.1592794807274085 |
acosh() | Math.acosh(4) //Equal to 2.0634370688955608 |
addEventListener() | |
altkey | function isKeyPressed(event) { if (event.altKey) { document.getElementsByTagName("p")[0].style.color = "#ff0000"; } else { alert("The ALT key was NOT pressed!"); } } |
appendChild | |
appCodeName | navigator.appCodeName |
appName | navigator.appName |
appVersion | navigator.appVersion |
asin() | Math.asin(-0.4) //Equal to -0.41151684606748806 |
asinh() | Math.asinh(20) //Equal to 3.6895038689889055 |
assign() | const target = { a: 1, b: 2 }; const source = { b: 4, c: 5 }; const returnedTarget = Object.assign(target, source); console.log(target); // expected output: Object { a: 1, b: 4, c: 5 } console.log(returnedTarget); // expected output: Object { a: 1, b: 4, c: 5 } |
atan() | Math.atan(20) //Equal to 1.5208379310729538 |
atanh() | Math.atanh(0.2) //Equal to 0.2027325540540822 |
attribute | |
availHeight | screen.availHeight |
boolean? a : b | 4===5? true : false //Equal to false |
break | |
cbrt() | Math.cbrt(8) //Equal to 2 |
ceil() | Math.ceil(2.145) //Equal to 3 |
charAt(num) | "nop".charAt(1) //Equal to "o" |
childNodes | var c = document.body.childNodes; c[0]; |
clearInterval() | clearInterval(setInterval(alert("Hi")),3000) |
click | |
colorDepth | screen.colorDepth |
confirm() | confirm("happy new year") |
concat() | [1,2,3,4].concat([5],[6]) //Equal to [1,2,3,4,5,6] |
console.log() | console.log("1+2") |
const | const a = "apple" //globle |
continue | |
copyWithin() | [1,2,3,4,5].copyWithin(2,1) //Equal to [1,2,2,3,4] |
cos() | Math.cos(32) //Equal to 0.8342233605065102 |
cosh() | Math.cosh(32) //Equal to 39481480091340.34 |
cost() | Math.cost() |
createElement() | var para = document.createElement("p") |
createTextNode() | document.createTextNode("This is new.") |
close() | window.close() |
Date() | var a = new Date() |
dblclick | |
do……while | var i = 0 do{ document.write(i) i++ }while(i<5) |
E | Math.E //Equal to 2.718281828459045 |
endsWith | "happy".endsWith("y") //Equal to true |
entries() | arrSet = {a:1,b:2,c:3} Object.entries(arrSet) //Equal to [["a",1],["b",2],["c",3]] |
eval() | eval("1+2") //Equal to 3 |
every() | [1,2,3,4,5].every(x => x<4) //Equal to false |
exp() | Math.exp(20) //Equal to 485165195.4097903 |
fill() | [1,2,3,4,5].fill("h") //Equal to ["h","h","h","h","h"] |
find() | [1,2,3,4,5].find(x => x>2) //Equal to 3 |
findIndex() | [1,2,3,4,5].find(x => x>2) //Equal to 2 |
flat() | [1,2,3,[4,5]].flat() //Equal to [1,2,3,4,5] |
floor() | Math.floor(2.145) //Equal to 2 |
freeze() | Object.freeze(obj) |
forEach() | [1,2,3,4,5].forEach((x,y)=>console.log(y+ "" +x)) |
for loop | for(i=0; i<6; i++){} |
for……in | |
for……of | |
from() | Array.from("12") //Equal to ["1","2"] |
function(){} | function(){ return "happy new year"; } \\Equal to () => "happy new year" |
getElementById(id) | document.getElementById("demo") |
getElementsByTagName(name) | getElementsByTagName("p") |
getElementsByClassName(name) | getElementsByTagName("demo") |
getTime() | new Date().getTime() //Equal to time from 1970.1.1 |
getFullYear() | new Date().getFullYear() //Equal to 2020 |
setFullYear() | new Date().setFullYear(2019) //Equal to 2019yr |
getUTCFullYear() | new Date().getUTCFullYear() //Equal to 2020 |
setUTCFullYear() | |
getMonth() | new Date().getMonth() //Equal to Month -1 |
setMonth() | |
getUTCMonth() | |
setUTCMonth() | |
getDate() | new Date().getDate() //Equal to today number |
setDate() | |
getNamedItem() | var x = btn.attributes.getNamedItem("class").value |
getUTCDate() | |
setUTCDate() | |
getDay() | new Date().getDay() //Equal to a week number |
setDay() | |
getUTCDay() | |
setUTCDay() | |
getHours() | new Date().getHours() //Equal to this hour number |
setHours() | |
getUTCHours() | |
setUTCHours() | |
getMinutes() | new Date().getMinutes() //Equal to this minute number |
setMinutes() | |
getUTCMinutes() | |
setUTCMinutes() | |
getSeconds() | new Date().getSeconds() //Equal to this seconds number |
setSeconds() | |
getUTCSeconds() | |
setUTCSeconds() | |
getMilliseconds() | new Date().getMilliseconds() //Equal to this milliseconds number |
setMilliseconds() | |
getUTCMilliseconds() | |
setUTCMilliseconds() | |
has() | |
height | screen.height //Equal to screen height |
hypot() | Math.hypot(3,4) //Equal to 5 |
includes() | [1,2,3,4,5].includes(5) //Equal to true |
indexOf() | "abcde".indexOf("b") //Equal to 1 |
Infinity | |
innerHeight | window.innerHeight //Equal to browser window height |
innerHTML | |
innerWidth | window.innerWidth //Equal to browser window width |
insertBefore() | element.insertBefore(para,child); |
isArray() | Array.isArray([1,2,3,4,5]) //Equal to true |
isFinite | isFinite(10/0) |
isInteger() | Number.isInteger(10/2) //Equal to true |
isNaN() | isNaN("123") //Equal to false |
isSafeInteger() | Number.isSafeInteger("2") //Equal to false |
item() | var x = a.attributes.item(1).value |
if……else if…… | if(x>1){ return true; }else{ return false; } |
join() | [1,2,3,4,5].join("") //Equal to "12345" |
lang | |
language | navigator.language |
languages | navigator.languages |
lastIndexOf() | [1,2,3,4,5].lastIndexOf(5) //Equal to 4 |
length | [1,2,3].length //Equal to 3 |
let | let a = "apple" //not global |
LN2 | Math.LN2 //Equal to 0.6931471805599453 |
LN10 | Math.LN10 //Equal to 2.302585092994046 |
location.href | location.href="https://www.google.com/" |
log() | Math.log(2) //Equal to 0.6931471805599453 |
LOG2E | Math.LOG2E //Equal to 1.4426950408889634 |
LOG10E | Math.LOG10E //Equal to 0.4342944819032518 |
map | [1,2,3,4,5].map(x => x*2) //Equal to [2,4,6,8,10] |
match() | "Str".match(/[a-z]/g) //Equal to ["t","r"] |
max | Math.max(1,2,3,4,5) //Equal to 5 |
nextSibling | |
nextElementSibling | |
min | Math.min(1,2,3,4,5) //Equal to 1 |
mousedown | |
mouseenter | |
mouseleave | |
mousemove | |
mouseover | |
mouseout | |
mouseup | |
moveTo(x,y) | |
name | var a = btn.atrributes.item(0).name |
NaN | |
nodeName | |
Number() | Number("12345") //Equal to 12345 |
Object.values() | const a = { a: 'somestring', b: 42, c: false }; Object.values(a) //Equal to ['somestring', 42, false] |
onblur() | |
onclick() | |
onerror() | |
onkeyup() | |
onkeydown() | |
onkeypress() | |
onfocus() | |
onload() | |
onmouseover() | |
onmouseup() | |
onmousedown() | |
onunload | |
onpaste | |
open() | window.open("https://www.google.com") |
onsubmit() | |
outerHeight | window.outerHeight //Equal to window.innerHeight + bar |
outerWidth | window.outerWidth //Equal to window.innerHeight + scroll |
padStart | last4Digits.padStart(card.length,"*") |
parseInt() | parseInt("2.456") //Equal to 2 |
parseFloat() | parseFloat("2.456") //Equal to 2.46 |
pixelDepth | screen.pixelDepth |
PI | Math.PI //Equal to 3.14159256 |
platform | navigator.platform //Equal to System name |
pop() | [1,2,3,4,5].pop() //Equal to 5 |
pow(x,y) | Math.pow(2,3) //Equal to 8 |
previousSibling | |
previousElementSibling | |
print() | window.print() |
product | navigator.product |
prompt() | prompt("happy new year") |
push() | [1,2,3,4,5].push("6") //Equal to [1,2,3,4,5,6] |
querySelector() | |
querySelectorAll() | |
reduce() | [1,2,3,4,5].reduce((a,b)=>a*b) //Equal to 120 |
reduceRight() | [1,2,3,4,5].reduce((a,b)=>a-b) //Equal to -5 |
random() | Math.random() //Equal to range [0-1] |
remove() | |
removeChild | |
removeEventListener() | |
removeNamedItem() | btn.attributes.removeNamedItem("value") |
repeat(num) | "12".repeat(2) //Equal to "1212" |
replace | var a = "Hi World" a.replace("Hi","No") //Equal to "No World" |
replaceChild | |
reverse() | [1,2,3,4,5].reverse() //Equal to [5,4,3,2,1] |
round() | Math.round(3.25) //Equal to 3 |
Set() | var arr = New Set() |
setInterval() | setInterval(alert("Hi"),3000) //Equal to alert("Hi") each 3s |
setNamedItem() | |
setTimeout() | setTimeout(alert("Hi"),3000) //Equal to alert("Hi") |
shift() | [1,2,3,4,5].shift() //Equal to 1 |
sin() | Math.sin(30) //Equal to -0.9880316240928618 |
sinh() | Math.sinh(30) //Equal to 5343237290762.231 |
slice() | [1,2,3,4,5].slice(1,2) //Equal to [2] |
some() | [1,2,3,4,5].some(x => x<2) //Equal to true |
sort() | [1,3,2,5,4].sort() //Equal to [1,2,3,4,5] |
specified | var btn = document.getElementsByTagName("BUTTON")[0]; var x = btn.getAttributeNode("onclick").specified; |
splice() | [1,2,3,4,5].splice(2,1) //Equal to [3] |
split() | "1234".split("") //Equal to ["1","2","3","4"] |
sqrt() | Math.sqrt(4) // Equal to 2 |
SQRT2 | Math.SQRT2 //Equal to 1.4142135623730951 |
SQRT1_2 | Math.SQRT1_2 //Equal to 0.7071067811865476 |
startsWith | "12345".startsWith("1") //Equal to true |
String() | String(12345) //Equal to "12345" |
switch | switch(x){ case 0 : return "happy"; break; } |
style.property | |
tan() | Math.tan(45) //Equal to 1.6197751905438615 |
tanh() | Math.tanh(-45) //Equal to -1 |
toFixed() | 1.23456.toFixed(3) //Equal to 1.235 |
toLowerCase() | "Happy".toUpperCase() //Equal to "happy" |
toString() | [1,2,3,4,5].toString() //Equal to "1,2,3,4,5" |
toString(2) | var a = 2; a.toString(2) //Equal to "10" |
toString(8) | var a = 16; a.toString(8) //Equal to "20" |
toString(16) | var a = 15; a.toString(16) //Equal to "f" |
toUpperCase() | "happy".toUpperCase() //Equal to "HAPPY" |
typeof n | typeof includes "number","string","boolean", etc |
undefined | var a !== undefined //Equal to false |
unshift() | [1,2,3,4,5].unshift(6) //Equal to [6,1,2,3,4,5] |
userAgent | navigator.userAgent |
value | var a = btn.atrributes.item(0).value |
var | var a = "apple" //global |
wheel | |
while | |
width | screen.width //Equal to screen width |
window | window.innerWidth //Equal to browser width |
write() | document.write("happy new year") |
writeIn() | document.writeIn("happy new year") |
+ | 1+2 //Equal to 3 |
- | 1-2 //Equal to -1 |
* | 1*2 //Equal to 2 |
/ | 1/2 //Equal to 0.5 |
** | 2**2 //Equal to 4 |
% | 2%1 //Equal to 0 |
++ | 2++ OR ++2 |
-- | 2-- OR --2 |
>= | x>=4 |
~ | ~5 |
^ | |
> | x>4 |
< | x<4 |
<= | x<=4 |
<< | |
>> | |
>>> | |
& | |
&& | true && true //Equal to true |
| | |
|| | true || false //Equal to true |
!= | true != false //Equal to true |
!== | true !== false //Equal to ture |
== | 4=="4" //Equal to true |
=== | 4==="4" //Equal to false |
Last updated