SlideShare a Scribd company logo
1 of 12
Download to read offline
Javascript
Methods & Events
By : Omar Hussein Mohamed
toString() (Array Method)
 The toString() method any type of data as a string .
 The toString() method doesn’t change the original string .
 The toString() can be used to convert a string object into a string .
let text = "Hello World!";
let result = text;
// result = Hello World! //
join() (Array Method)
 The join() method returns an array as a string .
 The join() method doesn’t change in the original array .
 Any separator can be specified. The default is comma (,).
const fruits = [“banana” , “Orange” , “Apple” , “Mango”];
let result = fruits.join();
// result = Banana,Orange,Apple,Mango//
contact() (Array Method)
 The concat() method joins two or more arrays.
 The concat() method returns a new array, containing the joined arrays.
 The concat() method does not change the existing arrays.
const arr1 = [“Javascript” , “C++” , “PHP”];
const arr2 = [“Python” , “Kotlin” , “html”];
let result = arr1.concat(arr2)
// result = Javascript,C++,PHP,Python,Kotlin,html//
some() (Array Method)
 The some() method checks if any of the elements in an array pass a test.
 The some() method does not change the original array.
 The some() method returns true (and stops) if the function returns true for one of the array
elements.
 The some() method returns false if the function returns false for all of the array elements.
const age = [3, 10 , 18 , 20];
function check(age) {
return age > 18;
}
let result = age.some(check);
// result = true //
every() (Array Method)
 every() returns true if all elements in an array pass a test (provided as a function).
 every() method returns true if the function returns true for all elements.
 every() method returns false if the function returns false for one element.
 every() method does not change the original array.
const age = [32, 33 , 16 , 40];
function check(age) {
return age > 18;
}
let result = age.every(check);
// result = false //
indexOf() (Array Method)
 The indexOf() method returns the first index (position) of a specified value.
 The indexOf() method returns -1 if the value is not found.
 The indexOf() method starts at a specified index and searches from left to right.
const code = [“html” , “javascript” , “python” , “php”];
let result = code.indexOf(“javascript”);
// result = 1 //
onmouseover (Event)
 The onmouseover event occurs when the mouse pointer enters an
element.
 The onmouseover event is often used together with the onmouseout
event, which occurs when the mouse pointer leaves the element.
onmouseout (Event)
 The onmouseout event occurs when the mouse pointer moves out of an
element.
 The onmouseout event is often used together with the onmouseover event,
which occurs when the pointer is moved over an element
onmousedown (Event)
 The onmousedown event occurs when a user presses a mouse button over an HTML element.
const text = document.createElement(‘p’);
Text.innerHTML = “Hello World”
Text.addEventListener(“mousedown” , ()=>{
text.style.color = “red”
})
//note : in addEventListener method we use only “mousedown”//
onmouseup (Event)
 The onmouseup event occurs when a mouse button is released over an element.
const text = document.createElement(‘p’);
Text.innerHTML = “Hello World”
Text.addEventListener(“mouseup” , ()=>{
text.style.color = “blue”
})
//note : in addEventListener method we use only “mouseup”//
Best Regards

More Related Content

Similar to Javascript Methods and events

33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
Below is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdfBelow is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdf
info673628
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
dickonsondorris
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
info309708
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
freddysarabia1
 
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdfStep 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
aloeplusint
 

Similar to Javascript Methods and events (20)

33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Below is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdfBelow is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdf
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
 
java assignment
java assignmentjava assignment
java assignment
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner code
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheetGeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheet
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
 
Java script array methods
Java script array methodsJava script array methods
Java script array methods
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
 
Extractors & Implicit conversions
Extractors & Implicit conversionsExtractors & Implicit conversions
Extractors & Implicit conversions
 
Collection and framework
Collection and frameworkCollection and framework
Collection and framework
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
Clone Refactoring with Lambda Expressions
Clone Refactoring with Lambda ExpressionsClone Refactoring with Lambda Expressions
Clone Refactoring with Lambda Expressions
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
 
Chapter 2 Java Methods
Chapter 2 Java MethodsChapter 2 Java Methods
Chapter 2 Java Methods
 
Chapter 2 Method in Java OOP
Chapter 2   Method in Java OOPChapter 2   Method in Java OOP
Chapter 2 Method in Java OOP
 
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdfStep 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
 
Ensure code quality with vs2012
Ensure code quality with vs2012Ensure code quality with vs2012
Ensure code quality with vs2012
 

More from Omar Hussein (6)

Fiber Optics 2022.pptx
Fiber Optics 2022.pptxFiber Optics 2022.pptx
Fiber Optics 2022.pptx
 
Tech Link Company's Profile
Tech Link Company's Profile Tech Link Company's Profile
Tech Link Company's Profile
 
Parabolic Antenna
Parabolic AntennaParabolic Antenna
Parabolic Antenna
 
Yahoo! marketing analyzing
Yahoo! marketing analyzing Yahoo! marketing analyzing
Yahoo! marketing analyzing
 
Optical Fiber
Optical Fiber Optical Fiber
Optical Fiber
 
Light Emitted Diode (LED)
Light Emitted Diode (LED) Light Emitted Diode (LED)
Light Emitted Diode (LED)
 

Recently uploaded

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

Javascript Methods and events

  • 1. Javascript Methods & Events By : Omar Hussein Mohamed
  • 2. toString() (Array Method)  The toString() method any type of data as a string .  The toString() method doesn’t change the original string .  The toString() can be used to convert a string object into a string . let text = "Hello World!"; let result = text; // result = Hello World! //
  • 3. join() (Array Method)  The join() method returns an array as a string .  The join() method doesn’t change in the original array .  Any separator can be specified. The default is comma (,). const fruits = [“banana” , “Orange” , “Apple” , “Mango”]; let result = fruits.join(); // result = Banana,Orange,Apple,Mango//
  • 4. contact() (Array Method)  The concat() method joins two or more arrays.  The concat() method returns a new array, containing the joined arrays.  The concat() method does not change the existing arrays. const arr1 = [“Javascript” , “C++” , “PHP”]; const arr2 = [“Python” , “Kotlin” , “html”]; let result = arr1.concat(arr2) // result = Javascript,C++,PHP,Python,Kotlin,html//
  • 5. some() (Array Method)  The some() method checks if any of the elements in an array pass a test.  The some() method does not change the original array.  The some() method returns true (and stops) if the function returns true for one of the array elements.  The some() method returns false if the function returns false for all of the array elements. const age = [3, 10 , 18 , 20]; function check(age) { return age > 18; } let result = age.some(check); // result = true //
  • 6. every() (Array Method)  every() returns true if all elements in an array pass a test (provided as a function).  every() method returns true if the function returns true for all elements.  every() method returns false if the function returns false for one element.  every() method does not change the original array. const age = [32, 33 , 16 , 40]; function check(age) { return age > 18; } let result = age.every(check); // result = false //
  • 7. indexOf() (Array Method)  The indexOf() method returns the first index (position) of a specified value.  The indexOf() method returns -1 if the value is not found.  The indexOf() method starts at a specified index and searches from left to right. const code = [“html” , “javascript” , “python” , “php”]; let result = code.indexOf(“javascript”); // result = 1 //
  • 8. onmouseover (Event)  The onmouseover event occurs when the mouse pointer enters an element.  The onmouseover event is often used together with the onmouseout event, which occurs when the mouse pointer leaves the element.
  • 9. onmouseout (Event)  The onmouseout event occurs when the mouse pointer moves out of an element.  The onmouseout event is often used together with the onmouseover event, which occurs when the pointer is moved over an element
  • 10. onmousedown (Event)  The onmousedown event occurs when a user presses a mouse button over an HTML element. const text = document.createElement(‘p’); Text.innerHTML = “Hello World” Text.addEventListener(“mousedown” , ()=>{ text.style.color = “red” }) //note : in addEventListener method we use only “mousedown”//
  • 11. onmouseup (Event)  The onmouseup event occurs when a mouse button is released over an element. const text = document.createElement(‘p’); Text.innerHTML = “Hello World” Text.addEventListener(“mouseup” , ()=>{ text.style.color = “blue” }) //note : in addEventListener method we use only “mouseup”//