[Learning]#13 JS: Intro to Data, Variables, Operators

Vida Lin
1 min readOct 1, 2021

Data: Number, String, Boolean

  • Number: e.g. 7, 17
  • String: consist of quotation marks and semicolon, e.g. “this is a string”;
  • Boolean: e.g. true, false

Variables

A variable is a container for storing data or values.
*Please note that it displays as the order we code.

Example

var x; → let's declare the variable as x.
x=17; → and we start to store value into the variable.
alert(x);
x="value";
alert(x);
var y=true;

Operators

Operators is like math formulas, consisting of various characters.
Let’s explain the formulas and terms by examples…

When we write

3+5; → Arithmetic operators
alert(3+5);

=> The result is 8.

var result=3*5; → Assignment operators
alert(result);

=> The result is 15.

Follow the last operator

result++; → increment (++) operators. It means the result has to plus 1, which can also be written as “result+1;”
alert(result);

=> The result is 16.

4<3; → Comparison operators.
result=4<3;
alert(result);

=> The boolean is “true.” If we write 4<3, the boolean is “false.”

var data=3;
result=data*data;
alert(result);

=> The result is 9.

alert(data);

=> The result is 3.

Music of Today: 酒鬼 Lasang Bastard by 張震嶽 ayal komod

Clap/Share/Follow

If you guys find this article helpful, please kindly do the writer a favor — giving 5 clicks at the GREEN area and 10~50 claps at the bottom of this page.

Most important of all, feel free to comment and share your ideas below to learn together!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Vida Lin
Vida Lin

Written by Vida Lin

PM, Relationship, Travel, or anything quirky but interesting.|Subscribe & buy Vida a drink @LikerLand, the bottom of each article. 在文章底下LikerLand訂閱、請Vida喝一杯飲料 ❤

No responses yet

Write a response