Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 5389

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 27, 20242024-11-27T08:47:06+00:00 2024-11-27T08:47:06+00:00

Starting Vanila Js as a noob….if you want get along on this journy. (1st day)

  • 61k

JS or JavaScript is a scripting language completely different from java. Js is used to add functionality or logic in html.
Below is the first thing you have to know which is console. Simply right click in your browser and click inspect. Here you can see the console. It is used to debug or test purpose in browser for js.

Below is the code snippet of different types of console log.
console.time('Your code took: ')
console.log('hello console');
console.log(4*4);
console.log(true);
console.log([34,67,43]);
console.log({himanshu:'this', marks: 34});
console.table({himanshu: 'this', marks:34});
console.warn('This is warning');
//console.clear();
console.timeEnd('Your code took: ');
console.assert(566<189, 'Age >189 does not exist');
console.error('This is an error');

As you can see there are different type of consoles.

  1. console.log(value) will print the value as it is.
  2. console.table(value) will print the value in table format.
  3. console.warn() will raise a warning massage in console tab.
  4. console.time(identifier variable) & console.timeEnd(same identifier variable as in “console.time()”) will return the time taken to execute the block of code within these two perameters.
  5. console.assert(value) will give a assertion(similar to warning) if condition not met.
  6. console.error() will give error massage.

Ok……So, I hope everything above should be as clear as water to you guys. Lets jump into next topic which is variables.

Variables are basically containers which hold the different values like numbers, letters or words. For example in maths when we solve algebra there is a most common problem we all might've faced “Find x” (don't worry you won't get your ex back…sheesh pj 🙂 ). Anyway there are variables in algebra like x and y with values like x=4 or x=5y something like that. So basically variables can store different types of values. I am bored now. Lets talk about real deal.

Moving forth there are three types of variables as far as I know till now in js.

  1. var
  2. let
  3. const
//Variable in js //var, let, const var name = 'Himanshu'; var marks = 3456; var channel;  console.log(name, channel, marks);  //Rules for creating Javascript variables  /* 1. Cannot start with numbers 2. Cannot start with letter, numbers, _ or $(can start with _ or $ but these use as identifires in many frameworks     which will give error eventually) 3. Are case sensitive */ var $example ='example' console.log($example)  const ownerName = 'Himanshu'; owerName = "Hari" console.log(ownerName); //const is a constant variable. is immutable // cant in left undefined  //let has block level scope  var city = 'Delhi'; // global scope console.log(city);  {     let city = 'Dubai';     console.log(city); }  console.log(city);  const arr1 = [12,34,23,54]; arr1.push(45);//in const variable array can push the value but can't redefine console.log(arr1);  /* Most common programming case types:  1. camelCase 2. kabab-case 3. snake_case 4. PascleCase  */   
Enter fullscreen mode Exit fullscreen mode

First lets talk about var.

Var is a global variable in js which can be accessed from anywhere in the code. But most developers try not to use var due to it's nature. Suppose we have 1000 lines of code and we used var with same name. It will raise a exception which might take us an eternity to identify.
In a nutshell var can be redefined means we can change the value of var.

Let……

Let variable has block level scope and {..this is scope..} all the things written within curly braces{} is in scope. We can redefine the let value out of the scope but it will give different value then the value which is defined in scope.

Const……

Const variable is immutable by nature means once defined can't be changed through out the the code. If we need a value to be static we use const. Like fields in a column or sirname etc.

Bonus tip: We can declare global values in a block by using window object.

for example
{ window.value = 100;}
alert(window.value).

What are the restrictions while initializing a vaiable?

We can use _ or $ to initialize a variable in js but it is recommended not use these because when we work with different libraries it may cause bugs.
Also we can't use * or number(1, 2, 3…..) to initialize the value.

Sorry for the long post. Here's a potato.

Image description

beginnersjavascriptprogrammingwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.