Base JavaScript Cheat Sheet

A Programming › JavaScript cheat sheet in English by Todin

A cheat sheet about the base of the programming language JS

4,277 views 1,042 downloads 26 Jan 2023 History

Language itself

Language for web 98% site use it create dynamic and intera­ctive web content like applic­ations and browsers
JS is an interp­reted language, it's a dynamic typing language and a weakly typed language.
As JS use a form of automatic memory management it's garbage collected.
JS is both an oriented object language and a functional language, the partic­ularity of it's OOP is in inheri­tance which is very complete and easy to use.

Language enviro­nment

To execute JavaScript in a browser you have two options either put it inside a script element anywhere inside an HTML document, or put it inside an external JavaScript file (with a . js extens­ion).
To run JS you only need a text editor and a web browser where you can execute it by implem­enting it in an html code, this means it's a multip­latform language whiwh can be used on all the OS and does not have any impact on your local machine.
If you want to run it in a terminal you need node.js.

Library

jQuery
It makes things simpler for HTML document manipu­lation and traversal, animation, event handling, and Ajax.
React.js
Just design a simple view for individual states in your app. Next, it will render and update the right component effici­ently upon data changes.
D3.js
Document manipu­lation based on data.
Lodash
JS utility library that makes it easier to work with numbers, arrays, strings, objects, etc.
Algolia Places
JavaScript library that provides an easy and distri­buted way of using address auto-c­omp­letion on your site. It’s a blazingly fast and wonder­fully accurate tool that can help increase your site user experi­ence.

To go further

The philosophy behind the creation of JS is simpli­city, compos­abi­lity, uniformity as the only progra­mming language native to the web browser.
JS is used for :
- Adding intera­ctive behavior to web pages
- Creating web and mobile apps
- Building web servers and developing server applic­ations
- Game develo­pment (in browser)

Syntax and data structures

consol­e.log()
print into the terminal
let a = b
create a mutable variable
const a = b
create an immutable variable
a + b
concat­enate if both string else if both numerical sum
`${a} text ${b}`
if printed show the value of the variable
if (condi­tio­n){Do someth­ing}; else if (){}; else {}
condition
for (var i = 0; i <= 11; i++){ Do something; }
for loop
while (condi­tion){ Do something; }
while loop
let arr = []
create an array
arr.push()
append the array
const readline = requir­e('r­ead­lin­e').c­re­ate­Int­erf­ace({ input: proces­s.s­tdin, output: proces­s.s­tdout }); readli­ne.q­ue­sti­on(­"­tex­t", (var) => { Do something ; readli­ne.c­lo­se(); })
to print text and take the answer from the terminal as a variable
class ClassName { constr­uct­or(­var­){t­his.var;} Method­(){}}
create a class

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.