DEV Community

Sivakumar Mathiyalagan
Sivakumar Mathiyalagan

Posted on

Basic JavaScript Questionnaires

What is JavaScript?

  • It is a High-level programming Language
  • Used to make webpages dynamic
  • It is a scripting language
  • It is Single threaded
  • It follows OOPs concept (Object-Oriented Programming)

High-level programming Language
A high-level programming language is a user-friendly, abstracted language designed for ease of use, enabling developers to write code in human-readable syntax

Used to make webpages dynamic
Normal a webpage with only HTML and CSS is of no use. In order to perform some operations or to make it interactive for the user, JavaScript need to be implemented along with HTML and CSS.

Scripting language
A scripting language is a programming language designed to automate the execution of tasks that would otherwise be executed one by one by a human operator
key features of scripting languages
Interpreted Execution: Scripting languages are typically interpreted rather than compiled.
(The code is executed line by line at runtime by a program called an interpreter, instead of being converted into a separate machine code file beforehand.)
Ease of Use: Scripting languages have simpler syntax, making them easier to learn, especially for beginners.
Dynamic Typing: Variables are typed at runtime, allowing more flexibility during execution.
Integration: Scripting languages are used to automate tasks by connecting and controlling different programs or system components.
High-Level Abstractions: They offer high-level features that simplify interaction with systems and applications.

Single threaded
JavaScript is a single-threaded language, meaning that it executes one operation at a time on a single thread. This characteristic is often misunderstood as a limitation, but JavaScript can still be non-blocking, which enables it to handle asynchronous operations(TBD) like reading from a file, fetching data from an API, or waiting for user input without blocking the main thread.

OOPs concept
features of Object-Oriented Programming
Encapsulation (TBD)
Abstraction (TBD)
Inheritance (TBD)
Polymorphism (TBD)


What are DataTypes?

Two types
Primitive and Non-Primitive

Primitive DataTypes

  1. String
  2. Number
  3. Boolean
  4. BigInt
  5. Symbol
  6. Null
  7. Undefined

Non-Primitive

  1. Object
  2. Array
  3. Functions
  4. Date(TBD)
  5. RegExp(TBD)
Feature Primitive Data Types Non-Primitive Data Types
Mutability Values are immutable Values are mutable
Data Complexity Stores single, simple values Stores complex or collection of values
Memory Storage Stored by value Stored by reference
Comparison Compared by value Compared by reference (two different objects are never equal even if content is same)
Memory Location Stored in stack memory Stored in heap memory

How to declare a variable?
Can be declared in four ways

Automatically without any keyword(not recommended)
Using var keyword(not recommended)
Using const keyword(recommended)
Using let keyword(recommended)

Automatically without any keyword
This allows to declare the same variable again and again which might lead to error so it is not recommended

Using var keyword

  • This was used till 2015 but it is also not recommended because this will also allow to initialize the same variable again and again
  • It is function scoped and doesnot provide block scope

const keyword
This is recommended if the value will not be changed in the future because if a variable is initialized with const key word then its value cannot be changed

let keyword
This is recommended if the value will be changed in the future

this provide block level scope for the variable unlike var

referrenced : https://www.w3schools.com/

GeeksforGeeks | Your All-in-One Learning Portal

Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

favicon geeksforgeeks.org

Top comments (0)