0% found this document useful (0 votes)
8 views

Javascript cheatsheet

The document provides an overview of various JavaScript functions, operators, and methods related to arrays, dates, DOM manipulation, events, and strings. It categorizes these elements into sections such as common functions, arithmetic operators, logical operators, and event handling. Additionally, it outlines specific functionalities and usage examples for each category, making it a comprehensive reference for JavaScript programming.

Uploaded by

Abdul Wasay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
8 views

Javascript cheatsheet

The document provides an overview of various JavaScript functions, operators, and methods related to arrays, dates, DOM manipulation, events, and strings. It categorizes these elements into sections such as common functions, arithmetic operators, logical operators, and event handling. Additionally, it outlines specific functionalities and usage examples for each category, making it a comprehensive reference for JavaScript programming.

Uploaded by

Abdul Wasay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
JAVASCRIPT iz fot vet ta coneatt copywithind indexof Includest joind entries every fio fitter find foreach fromo lastindexof)) Pop0 pusho reverse) RRAYS Join several arrays into one copy orray elements within the array, to.and from specified positions return the primitive value of the specified abject check if on orray contains the specified element combine elements of an ‘array into. single string ‘and return the string return a keyWvalue pair array iteration object check if every element in an orray passes o test {ill the elements in an array with a static value create a new array with every element in an array that pass a test return the value of the first element in an array that pass a test calla function for each array element create an array from on object give the last position at which a given element ‘appears in an array remove the last element of an avray ‘add @ new element at the end sort elements in descending order reduced reducerighti) shift sliced sortd spliced unshifto ARRAYS reduce the values of an array to single value [going left-to-right) reduce the values of an array to a single value (going right-to-teft) remove the first element of an array pull a copy of a portion of an array into. new array of, 42H sort elements alphabetically add elements in a specified ‘way and position add a new element to the beginning COMMON FUNCTIONS alert confirmi) consolelogd document.write prompt tostringd ‘output data in an alert box in the browser window ‘open up a yes/no dialog cond return true/false depending on user click write information to the browser console (good for debugging purposes) ‘write directly to the html document, create a dialog for user input convert a boolean value to string, and return the result JAVASCRIPT ARITHMETIC OPERATORS Addition Subtraction Multiplication Division Grouping Operator ‘Modulus (Remainder) Increment Numbers Decrement Numbers Equal To Equal Value And Equal Type Not Equal ‘Not Equal Value Or Not Equal Type Greoter Than Lesser Than Greater Than Or Equal To Lesser Than Or Equal To Temary Operator LOGICAL OPERATORS Logical AND Logical OR Logical NOT while do white for..in loop for..of Loop break continue BITWISE OPERATORS AANO Stoternent oR STATEMENT Not not Left Shift Right Shift Zero Fil Right Shift JAVASCRIPT LOOPS for (let 1=0;1< 5; i++) [ fe something 5 while (condition) ( Ido something i dot Ido something while (condition) for tet hey in ob) ( 140 something ) for let element of art { iI é0 something i stop and exit the cycle if certain conditions are mets skip ports of the cycle if certain conditions are met dated gettimed getfullyeard getmontho getdatel getdayo gethoursd getminutes)) getsecondso getmillisecondso setfullyeard ssetmonth() setdateo sethours) setminutest) setseconds)) setmilliseconds)) DATES creates « new date object returns the number of milliseconds since january 41,1970 returns the year of the specified date returns the month of the specified date (0-11), returns the day of the ‘month ofthe specined date (31) returns the day of the week of the specified date (0-6), returns the hour of the specified date (0-23) returns the minute of the specified date (0-58) returns the second of the specified date (0-59) returns the millisecond of the specified date (0-239) sets the year of the specified date sets the month of the specified date (0-11), sets the day of the month of the specified date (1-31) sets the hour of the specified date (0-23) sets the minute of the specified date (0-59) sets the second of the specified date (0-59). sets the millisecond of the specified date (0-999) DOM METHODS dear createdacumentt createdacument fragmento createetement) createeventi createeventodject createranged createtextnodet) getelementsbytag amet) getelementbyidd write clears output creates a new html document creates a new empty ocumentfragment node. creates a new htm element creates a new event abject creates a new event object {for le) creates a new range object, creates 6 new text node returns an array of elements, with a specified tag name returns an element with a specified 1D ‘writes html expressions to a document ‘TYPES OF FUNCTIONS named function ‘ononymous function immediately invoked function expression (iF) function myfunctiond ( console.logt" follow me”); ) var myfunction = function® ( consolelog(do it"); 1 (function ¢ consoleloatnow. MM; FORM EVENTS FRAME EVENTS onblur when an element loses, onabort ‘when loading of media is focus aborted onchange triggers when a form onbeforeuntoad before the document is element value is changed about to be unloaded onfocus when an element gets focus onerror when an error occurs while loading an extern fle confocusin triggers when an element receives focus ‘onhashchange when the anchor part of a urLhas changed onfocusout triggers when an element loses focus onload when an object has loaded oninput ser input on an element onpagehide ‘when user navigates away from a webpage oninvatid when an element is invalid ‘onpageshow when user navigates to a onreset when o form is reset webpage onsearch triggers when the user onresize when user resizes document searches within a search view input onscroll when user is scrolling an onselect when user selects some text element’ scrollbar fonsubmit when o form is submitted ‘onuntoad when a page has unloaded DRAG EVENTS KEYBOARD EVENTS ondrag when user drags an element ‘onkeydown when user is pressing a key down ondragena when user hos finished dragging the element conkeypress when user starts pressing a ondragenter when the dragged element ™ enters a drop target, onkeyup when user releases a ey ondragleave when the dragged element leaves the drop target ondragover when the dragged element ison top of the drop target condragstart when user starts to drag an element ondrop dragged element is dropped on the drop target, ESCAPE CHARACTERS v wv v w \t w single quote double quote backslash backspace form feed new line corriage return horizontal tabulator vertical tabulator JAVASCRIPT MOUSE EVENTS. onclick oncontextmenu ondblclick ‘onmousedown onmouseenter ‘onmouseleave ‘onmouseout ‘onmouseover ‘onmouseup 0 user clicks on an element ‘user right-clicks on on element user double-clicks on an element ‘@ mouse button is pressed over an element the mouse pointer moves into an element the mouse pointer moves ut of an element the mouse pointer moves ver an element. the mouse pointer moves ut of an element the mouse pointer moves onto.an element 2 mouse button is released over an element. chorato charcodeat concati fromchorcoded indexofd {astindexofd match replaced search sliced split substro substring) tolowercased) touppercased STRING METHODS tetuen a character at a specified position inside a string give the unicode of Character at that position concatenate join) two or more strings into one return a string created from the specified sequence of utf-16 code units provide the position of the first occurrence of specified text within a string same os indexoft but with the last occurrence, searching backwards retrieve the matches of a string against a search pattern find and replace specified text ina string execute a search for a matching text and return its position extract section of a string ‘ond return itas @ new string divides a string into on ‘orray extracts a portion of a string similar to sliced) but can't accept negative indices convert strings to lowercase convert strings to uppercase

You might also like