What i learnt about JavaScript in a week. #1

Prakash Pawar
3 min readJun 27, 2018

--

Photo by Max Nelson on Unsplash

Hey! i am Prakash and today i am going to share my experience with JavaScript in my first 7 days of learning. I am going to make this Post short like TL;DR and make it like Cheat Sheet that is understandable for beginners with little bit knowledge like me.

In this this part i am going to talk about Variables, Operators, and Objects.

Variables :

Variable is like dish that you need every time you eat something yeah i know its a silly example. okay now just understand this few things about Variables :

  1. Variable is used to store data temporarily in the system memory. var is assigned /reserved keyword.
  2. You should give variable a name to Recognize it later. Example //var myName = ‘prakash’; // here ‘myName’ is name, ‘=’ is assigned operator and ‘prakash’ is value.
  3. JavaScript is Dynamic Language so it would automatically recognize the value type (such as String, Number, Boolean ..etc.)
  4. There are few Rules that you should follow while giving a name to variable :
  5. a) the name cannot be same as Reserved Keywords(like var,this, const,let,if … etc, do Research on Reserved words.).
  6. b) you cannot start a variable name with a number.(var 1name; // just don’t do this.) and also don’t use any space or slash symbol( — ) it’s not allowed.(var java script; or var java-script //wrong way !).
  7. c) var names are Case Sensitive. (var jaVasCript; and var javaScript; will display as different variables).
  8. d) this thing you can do or i say you must DO, use Camel Notation (yes something we can do), Camel Notation is a best practice to give names in JavaScript (Examples : var javaScript; var myFirstName; var goodMorningNewYork;).
  9. After ES5, Variables has two types : a) const and b) let ,
  10. a) const is used for the value that is constant we we don’t have any intention to change that in future.
  11. b) let is used for changeable values in JavaScript.

Operators :

Quick Notes about operators , just remember two types of Operators : a)Binary and b) Unary.

  1. a) Binary needs two Operands and one Operator to perform operation.(example: a * b; 5 + 6 = 11; here a,b,5 and 6 are Oprands and ‘*’ and ‘+’ are Operators.)
  2. b) Unary needs one Oprand and two Operator.(Example:y++; ++x;).

Objects:

Everything Consist a value is an Objects( If they are not Primitive but even Primitives acts like objects). but we are not gonna Escape Primitives so here are types of Primitive :

  1. String: is any value between quotation marks. ( “hey”, ’123’ “1one”)
  2. Boolean: true or false.(var aboveAdultAge = true;)
  3. Number: use numbers without quotations. (Var length= 10; var width=20;)
  4. Undefined: not defined yet.( Var wait; // if you call this it will show undefined)
  5. Null: if you set it null means var don’t have any value.
  6. Symbol: In ES5-6 symbols are introduced. (♥️,🐈,🎂).

Objects are big Deal in JavaScript , as i said Everything that isn’t Primitive are Objects. Functions, Arrays and many more. Here is a catch, two name get changed in Objects , Functions known as Methods and Variables known as Properties in Objects.

Here is the Example of Object superman:

var superMan={ realName: ‘Clark Kent’, powerLimited: false, from: ‘Krypton’, age: 33};

Here are few small things about abovr example that Important to remember otherwise later you will get confuse.

  1. The Syntax i used in example is Object Literal Notation Syntax.
  2. realName, powerLimited, from, age are all properties of Object.
  3. Don’t use semi-colon inside of object. use comma to separate properties.
  4. Don’t use assigned operator(= ) instead use colon ( : ) .

In next part i am going to cover the rest(about Object Notations, Arrays and Functions) i learnt about JavaScript.

Thanks for reading.

--

--

Prakash Pawar

Curious to learn about universe and beyond. Learning Web Development.