Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
10 views
Js
js basics
Uploaded by
ramagoddy
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save js For Later
Download
Save
Save js For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
10 views
Js
js basics
Uploaded by
ramagoddy
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save js For Later
Carousel Previous
Carousel Next
Save
Save js For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 10
Search
Fullscreen
‘wraai24, 229 AM Projects | 100x005 Javascript 101 1of5 ritpssprojects.100xcovs.com/plfjavascript-1Wavaseript 101-1 10‘912824, 9:39 AM Projects | 100xDevs 5 https://x.com/__Raiders/status/1820089916287828123 = j, Jovascriptol tofS + 5044/status/1820090993045020979 Bounty = $25 to each of you! Javascript - The basics Web development Web development involves writing a lot of HTML, CSS and JS code. Historically (and even today to some extend), browsers could only understand HTML, CSS and JS Any website that you see, is a bunch of HTML, CSS and JS files along with some assets (images, videos etc) Facts/Callouts 1. React, NextJS are frameworks . They compile down to HTML, CSS, JS in the end. That is what your browser understands. 2. When you run your C++ code on leeteode , it does not run on your browser/machine. It runs somewhere else. Your browser can't (almost) htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 2110‘912824, 9:39 AM Projects | 100xDevs 3.l€ someone asks — What all languages can your browser interpret, the =}! Javascript 101 1ofs JS and WebAssembly. It can, technically, run v++*/RUST Code that is compiled down to Wasm Before we proceed, do one of the following - 1. Create an account on replit 2, Install Node,js locally 3. Keep your browser console open for testing locally Properties of JS Every language comes with it's unique set of features. Javascript has the following - 1. Interpreted JavaScript is an interpreted language, meaning it's executed line-by-line at runtime by the JavaScript engine in the browser or server environment, rather than being compiled into machine code beforehand. Upsides = unning your code Downsides = htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 30‘912824, 9:39 AM Projects | 100xDevs 1 Performance Overhead: =, Javascript 101 1of5 he errors 2. Dynamically Typed Variables in JavaScript are not bound to a specific data type. Types are determined at runtime and can change as the program executes C++ Code (won't compile) #include
© int main() { int a =1; a = "hello"; a = true; } JS Code (will compile) a= true; console log(a) 3. Single threaded JavaScript executes code in a single-threaded environment, meaning it processes one task at a time. We will dive deeper into this next week. htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 ano‘912824, 9:39 AM Projects | 100xDevs 4 Garhane collected = __ Javascript 101 1of . - — «eully Manages memory allocation and deallocation through garbage collection, which helps prevent memory leaks by automatically reclaiming memory used by objects no longer in use. Conclusion Is JS a good language? Yes and no. It is beginner friendly, but has a lot of performance overhead. Bun is trying to solve for a lot of this, but there’s a long way to go before JS can compete with languages like C++/Rust Syntax of Javascript 1. Variables Variables are used to store data. In JavaScript, you declare variables using var, let, OF const. let name = "John", // Variable that can be reassigned © const age = 30; —_// Constant variable that cannot be reassigned :clare variables, function-scoped Y Assignment htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 510sw224, 999 AM Projects | 100:00re Create a variable for each of the following: your favorite color, your i€ Javascript 101 1ofs i, ANd whether you like pizza. Use appropriate valiuvre aeciuruuans (let, const, or var ). Try logging it using consolelog 2. Data types let number = 42; || Number © let string = "Hello World’; // String let isActive = false; —_// Boolean let numbers = [12,3]; // Array 3. Operators let sum = 10 + 5; // Arithmetic operator ® let isEqual = (10 === 10); // Comparison operator let isTrue = (true && false); // Logical operator 4. Functions || Function declaration © function greet(name) { return "Hello, " + name; } || Function call let message = greet("John’); // “Hello, John” V Assignment #1 Write a function sum that finds the sum of two numbers. Side quest - Try passing in a string instead of a number and see what happens? v Assignment #2 Write a function called canvote that returns true or false if the age of a htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 610‘912824, 9:39 AM Projects | 100xDevs 5. 1t/Else = Javascript 101 1of 5 console.log("You are an adult); yelse { console.log("You are a minor.’); } v Assignment Write an if/else statement that checks if a number is even or odd. If it's even, print "The number is even,’ Otherwise, print "The number is odd." 6. Loops |] For loop © for (let i = 0;i < 5; i++) { console.log(i); // Outputs 0 to 4 } 1] While loop let j = 0; while (j <5) { console.log(j); // Outputs 0 to 4 itt; } ¥ Assignment Write a function called sum that finds the sum from 1to a number htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 70‘912824, 9:39 AM Projects | 100xDevs 7mnlev types = Javascript 101 1of5 Objects An object in JavaScript is a collection of key-value pairs , where each key is a string and each value can be any valid JavaScript data type, including another object. console.log("Harkirats age is " + user.age); Vv Assignment #1 Write a function that takes a user as an input and greets them with their name and age Vv Assignment #2 Write a function that takes a new object as input which has name , age and gender and greets the user with their gender (Hi Mr/Mrs/others harkirat, your age is 21) v Assignment #3 Also tell the user if they are legal to vote or not Arrays Arrays let you group data together const tatalUsers = users.length; htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 anosw224, 999 AM Projects | 100:00re const firstUser = users[0]; =, Javascript 101 ofS Write a function that takes an array of numbers as input, and returns a new array with only even values. Read about filter in JS Array of Objects We can have more complex objects, for example an array of objects const users = [{ © name: ‘Harkirat, const userl = users[0] const userlAge = users[0].age Vv Assignment Write a function that takes an array of users as inputs and returns only the users who are more than 18 years old Object of Objects We can have an even more complex object (object of objects) const userl = { © name: ‘harkirat’, age:19, address: { city: "Delhi", country: "India". htps:ifprojects.100xdevs.comipatjavascript1/Javascript-101-4 eno‘112824, 9:39 AM Projects | 100x005 } E ¢ davascript 0 1018 3.5 city: Y Assignment Create a function that takes an array of objects as input, and returns the users whose age > 18 and are male ntps:ifprojects.100xdevs.comipatjavasctipt-1/Javascrip-101-1 s0110
You might also like
3 - Javascript JQuery-MTD
PDF
No ratings yet
3 - Javascript JQuery-MTD
52 pages
Intro&Basics.pptx
PDF
No ratings yet
Intro&Basics.pptx
73 pages
Group 1 - Overview of JavaScript
PDF
No ratings yet
Group 1 - Overview of JavaScript
57 pages
JavaScript Document
PDF
No ratings yet
JavaScript Document
23 pages
Overview of Javascript
PDF
No ratings yet
Overview of Javascript
16 pages
Unit 3-Javascript (1)
PDF
No ratings yet
Unit 3-Javascript (1)
73 pages
Chapter 4 Javascript
PDF
No ratings yet
Chapter 4 Javascript
80 pages
Chapter 4 - Javascript in Webdev
PDF
No ratings yet
Chapter 4 - Javascript in Webdev
21 pages
Introduction To Javascript: Unit-2 Syllabus
PDF
No ratings yet
Introduction To Javascript: Unit-2 Syllabus
340 pages
Web Engineering Javascript (Part 1) : Muhammad Umair Naru Department of Computer Science
PDF
No ratings yet
Web Engineering Javascript (Part 1) : Muhammad Umair Naru Department of Computer Science
24 pages
Javascript Class.docx
PDF
No ratings yet
Javascript Class.docx
89 pages
JavaScript
PDF
No ratings yet
JavaScript
11 pages
Web Programmingqb
PDF
No ratings yet
Web Programmingqb
145 pages
Java Script
PDF
No ratings yet
Java Script
29 pages
Chapter 4 JS
PDF
No ratings yet
Chapter 4 JS
29 pages
Javascript Updated
PDF
No ratings yet
Javascript Updated
117 pages
Javascript
PDF
No ratings yet
Javascript
8 pages
Javascript Notes1
PDF
No ratings yet
Javascript Notes1
12 pages
What Is Javascript?: Javascript Is Interpreted by The Browser. Js Code Is Typically Embedded Right in HTML Pages
PDF
No ratings yet
What Is Javascript?: Javascript Is Interpreted by The Browser. Js Code Is Typically Embedded Right in HTML Pages
21 pages
Unit3-Basics of JavaScript
PDF
60% (5)
Unit3-Basics of JavaScript
62 pages
Chapter 4 - Javascript
PDF
No ratings yet
Chapter 4 - Javascript
29 pages
21 Javascript
PDF
No ratings yet
21 Javascript
79 pages
Java Script CheatSheet
PDF
No ratings yet
Java Script CheatSheet
31 pages
C4 Week1
PDF
No ratings yet
C4 Week1
56 pages
Web Tech 2
PDF
No ratings yet
Web Tech 2
93 pages
M1 FS IA1
PDF
No ratings yet
M1 FS IA1
24 pages
Javascript Fund1
PDF
No ratings yet
Javascript Fund1
78 pages
Javascript Notes
PDF
No ratings yet
Javascript Notes
60 pages
Javascript-1
PDF
No ratings yet
Javascript-1
71 pages
Web Dev JS sammary
PDF
No ratings yet
Web Dev JS sammary
25 pages
Website JavaScript
PDF
No ratings yet
Website JavaScript
50 pages
Introductory JavaScript
PDF
No ratings yet
Introductory JavaScript
6 pages
JavaScript Basics
PDF
No ratings yet
JavaScript Basics
12 pages
JavaScript Tech Move
PDF
No ratings yet
JavaScript Tech Move
1 page
Javascript Basic
PDF
100% (2)
Javascript Basic
28 pages
JavaScript ppt
PDF
No ratings yet
JavaScript ppt
123 pages
Iw 7
PDF
No ratings yet
Iw 7
49 pages
Javascript - Intro
PDF
No ratings yet
Javascript - Intro
27 pages
Lecture 3
PDF
No ratings yet
Lecture 3
60 pages
Backend Lecture 2 Javascript
PDF
No ratings yet
Backend Lecture 2 Javascript
25 pages
Javascript The Basics
PDF
No ratings yet
Javascript The Basics
58 pages
Javascript
PDF
No ratings yet
Javascript
95 pages
04 JavaScript
PDF
No ratings yet
04 JavaScript
58 pages
Javascript
PDF
No ratings yet
Javascript
19 pages
Crisostomo Assignment MC
PDF
No ratings yet
Crisostomo Assignment MC
5 pages
Client-Side Programming: The Javascript Language
PDF
No ratings yet
Client-Side Programming: The Javascript Language
161 pages
Javascript Unit2 PDF
PDF
No ratings yet
Javascript Unit2 PDF
51 pages
Web Technology II - JavaScript
PDF
No ratings yet
Web Technology II - JavaScript
120 pages
CSS (22519)
PDF
No ratings yet
CSS (22519)
8 pages
S4 S6 S7 S8 S9 - JavaScript
PDF
No ratings yet
S4 S6 S7 S8 S9 - JavaScript
78 pages
Javascript Cheat Sheet
PDF
No ratings yet
Javascript Cheat Sheet
43 pages
Java Script: Variables &scope, Data Types, Control Structures, Array Methods
PDF
No ratings yet
Java Script: Variables &scope, Data Types, Control Structures, Array Methods
35 pages
Block I & II - Scripting Language
PDF
No ratings yet
Block I & II - Scripting Language
36 pages
Lecture JavaScript
PDF
No ratings yet
Lecture JavaScript
91 pages
JavaScript
PDF
No ratings yet
JavaScript
14 pages
Java Script
PDF
No ratings yet
Java Script
193 pages
Javascript - Part 1: It1100 - Internet and Web Technologies
PDF
No ratings yet
Javascript - Part 1: It1100 - Internet and Web Technologies
52 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
3 - Javascript JQuery-MTD
PDF
3 - Javascript JQuery-MTD
Intro&Basics.pptx
PDF
Intro&Basics.pptx
Group 1 - Overview of JavaScript
PDF
Group 1 - Overview of JavaScript
JavaScript Document
PDF
JavaScript Document
Overview of Javascript
PDF
Overview of Javascript
Unit 3-Javascript (1)
PDF
Unit 3-Javascript (1)
Chapter 4 Javascript
PDF
Chapter 4 Javascript
Chapter 4 - Javascript in Webdev
PDF
Chapter 4 - Javascript in Webdev
Introduction To Javascript: Unit-2 Syllabus
PDF
Introduction To Javascript: Unit-2 Syllabus
Web Engineering Javascript (Part 1) : Muhammad Umair Naru Department of Computer Science
PDF
Web Engineering Javascript (Part 1) : Muhammad Umair Naru Department of Computer Science
Javascript Class.docx
PDF
Javascript Class.docx
JavaScript
PDF
JavaScript
Web Programmingqb
PDF
Web Programmingqb
Java Script
PDF
Java Script
Chapter 4 JS
PDF
Chapter 4 JS
Javascript Updated
PDF
Javascript Updated
Javascript
PDF
Javascript
Javascript Notes1
PDF
Javascript Notes1
What Is Javascript?: Javascript Is Interpreted by The Browser. Js Code Is Typically Embedded Right in HTML Pages
PDF
What Is Javascript?: Javascript Is Interpreted by The Browser. Js Code Is Typically Embedded Right in HTML Pages
Unit3-Basics of JavaScript
PDF
Unit3-Basics of JavaScript
Chapter 4 - Javascript
PDF
Chapter 4 - Javascript
21 Javascript
PDF
21 Javascript
Java Script CheatSheet
PDF
Java Script CheatSheet
C4 Week1
PDF
C4 Week1
Web Tech 2
PDF
Web Tech 2
M1 FS IA1
PDF
M1 FS IA1
Javascript Fund1
PDF
Javascript Fund1
Javascript Notes
PDF
Javascript Notes
Javascript-1
PDF
Javascript-1
Web Dev JS sammary
PDF
Web Dev JS sammary
Website JavaScript
PDF
Website JavaScript
Introductory JavaScript
PDF
Introductory JavaScript
JavaScript Basics
PDF
JavaScript Basics
JavaScript Tech Move
PDF
JavaScript Tech Move
Javascript Basic
PDF
Javascript Basic
JavaScript ppt
PDF
JavaScript ppt
Iw 7
PDF
Iw 7
Javascript - Intro
PDF
Javascript - Intro
Lecture 3
PDF
Lecture 3
Backend Lecture 2 Javascript
PDF
Backend Lecture 2 Javascript
Javascript The Basics
PDF
Javascript The Basics
Javascript
PDF
Javascript
04 JavaScript
PDF
04 JavaScript
Javascript
PDF
Javascript
Crisostomo Assignment MC
PDF
Crisostomo Assignment MC
Client-Side Programming: The Javascript Language
PDF
Client-Side Programming: The Javascript Language
Javascript Unit2 PDF
PDF
Javascript Unit2 PDF
Web Technology II - JavaScript
PDF
Web Technology II - JavaScript
CSS (22519)
PDF
CSS (22519)
S4 S6 S7 S8 S9 - JavaScript
PDF
S4 S6 S7 S8 S9 - JavaScript
Javascript Cheat Sheet
PDF
Javascript Cheat Sheet
Java Script: Variables &scope, Data Types, Control Structures, Array Methods
PDF
Java Script: Variables &scope, Data Types, Control Structures, Array Methods
Block I & II - Scripting Language
PDF
Block I & II - Scripting Language
Lecture JavaScript
PDF
Lecture JavaScript
JavaScript
PDF
JavaScript
Java Script
PDF
Java Script
Javascript - Part 1: It1100 - Internet and Web Technologies
PDF
Javascript - Part 1: It1100 - Internet and Web Technologies