• Home
  • What is ?
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Quiz
  • YT
  • Home
  • What is ?
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Quiz
  • YT
  • #News
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk
  • #Interview
  • #Tips

MyCodeTips mycodetips-newlogocopy1

  • Home
  • What is ?
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Quiz
  • YT
Javascript

JavaScript Cheatsheets or Basics Reference

The JavaScript language itself, as a format, is free, and the use of JavaScript in a website is not necessarily. JavaScript Cheatsheets contain useful code examples on a single page. … Find code for JS loops, variables, objects, data types, strings, events, and many.

Javascript is the most popular programming language in the world and that makes it a programmer’s great choice. Once you learned Javascript, it helps you developing great front-end as well as back-end software using different Javascript-based frameworks like jQuery, Node.JS, etc.

JavaScript Cheatsheets helps you create really beautiful and crazy fast websites. You can develop your website with a console-like look and feel and give your users the best Graphical User Experience.
The great thing about JavaScript Cheatsheets is that you will find tons of frameworks and Libraries already developed which can be used directly in your software development to reduce your time to market.

console.log()

console.log('Hi there!');
// Prints: Hi there!

Strings

let single = 'Wheres my project code?';
let double = "Wheres my project code?";

Numbers

let amount = 6;
let price = 4.99;

Booleans

let lateToWork = true;

Null

let x = null;

Arithmetic Operators

+ addition
- subtraction
* multiplication
/ division
% modulo


// Addition
5 + 5
// Subtraction
10 - 5
// Multiplication
5 * 10
// Division
10 / 5
// Modulo
10 % 5

String .length

let message = 'good night';
console.log(message.length);
// Prints: 10
 
console.log('howdy'.length);
// Prints: 5

Math.random()

console.log(Math.random());
// Prints: 0 - 0.9

Math.floor()

console.log(Math.floor(5.95)); 
// Prints: 5

Single Line Comments

// This line will denote a comment

Multi-line Comments

/*  
The below configuration must be 
changed before deployment. 
*/

Remainder / Modulo Operator

// calculates # of weeks in a year, rounds down to nearest integer
const weeksInYear = Math.floor(365/7);
 
// calcuates the number of days left over after 365 is divded by 7
const daysLeftOver = 365 % 7 ;
 
console.log("A year has " + weeksInYear + " weeks and " + daysLeftOver + " days");

Javascript Variables

// examples of variables
let name = "Mycodetips";
const found = false;
var age = 3;
console.log(name, found, age);
// Mycodetips, false, 3

const Keyword

const numberOfColumns = 4;
numberOfColumns = 8;
// TypeError: Assignment to constant variable.

let Keyword

let count; 
console.log(count); // Prints: undefined
count = 10;
console.log(count); // Prints: 10

Assignment Operators

+= addition assignment
-= subtraction assignment
*= multiplication assignment
/= division assignment
let number = 100;
 
// Both statements will add 10
number = number + 10;
number += 10;
 
console.log(number); 
// Prints: 120

String Concatenation

let service = 'credit card';
let month = 'May 30th'; 
let displayText = 'Your ' + service  + ' bill is due on ' +  month + '.';
 
console.log(displayText);
// Prints: Your credit card bill is due on May 30th.

Variables

const currency = '$';
let userIncome = 85000; 
 
console.log(currency + userIncome + ' is more than the average income.');
// Prints: $85000 is more than the average income.

Declaring Variables

var is used in pre-ES6 versions of JavaScript.
let is the preferred way to declare a variable when it can be reassigned.
const is the preferred way to declare a variable with a constant value.
var age;
let weight;
const numberOfFingers = 20;

Happy Coding on JavaScripting 🙂

Liked it? Take a second to support Ranjan on Patreon!
Become a patron at Patreon!
  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 676 Views
Tags | javascript, SCRIPT
AUTHOR
Ranjan

Namaste, My name is Ranjan, I am a graduate from NIT Rourkela. This website is basically about of what i learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures, its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

You Might Also Like

js-cheatsheets-advance-operators

JavaScript Objects CheatSheets, Operators & Quantifiers

July 24, 2021
mycodetips-newlogo2

How to change colour of font using javascript

September 24, 2013
js-cheatsheets-advance-methods

JavaScript Methods & Properties CheatSheets

July 25, 2021
Next Post
Previous Post

Support us

mycodetips
mycodetips

Follow us @ LinkedIn 2850+

Subscribe for updates

Join 8,213 other subscribers

Latest Posts

  • YT-Featured-solidprinciples
    SOLID Principles of Software Design
  • IOS 16 Features
    Latest features in IOS 16
  • r-language
    How can R language be used for data analysis?
  • wordpress-coding-blog
    Guide To WordPress Coding Standards
  • YT-Featured-Algorithm
    What is Algorithm?
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

Android Android Studio API APP Programming Apps blogging CSS DATABASE dsa Features HTML HTML5 installation Interview Questions IOS iPhone javascript Mac objective-c OS Programming quicktips SDK SEO SQL swift Tips & Tricks Tools UI Web Wordpress Xcode

  • SOLID Principles of Software Design
  • Latest features in IOS 16
  • How can R language be used for data analysis?
  • Guide To WordPress Coding Standards
  • What is Algorithm?

©mycodetips.com