Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
JavaScript typedArray.indexOf() Method
Next article icon

JavaScript typedArray.includes() Method

Last Updated : 10 Feb, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

The typedArray.includes() is an inbuilt function in JavaScript which is used to check whether a particular element is included by the given typedArray or not and accordingly it returns true and false. 

Syntax:

typedarray.includes(Element, Index);

Parameters: It accepts two parameter which are specified below-

  • Element: It is the element which are being searched in the typedArray.
  • Index: It is the index of the element in the typedArray form where search should start. Its default value is zero (0) and it is optional.

Return value: It returns a boolean value true if the element is present in the given typedArray otherwise returns false.

Example 1:

javascript




// Creating some typedArrays
const A = new Uint8Array([ 1, 2, 3, 4, 5 ]);
const B = new Uint8Array([ 5, 10, 15, 20 ]);
const C = new Uint8Array([ 0, 2, 4, 6,, 8, 10 ]);
const D = new Uint8Array([ 1, 3, 5, 7, 9 ]);
  
// Calling include() function
a = A.includes(2)
b = B.includes(15, 1)
c = C.includes(6)
d = D.includes(9, 1)
  
// Printing true or false, either the element
// is present in the typedArray or not
console.log(a);
console.log(b);
console.log(c);
console.log(d);
 
 

Output:

true  true  true  true

Example 2: 

javascript




// Creating some typedArrays
const A = new Uint8Array([ 1, 2, 3, 4, 5 ]);
const B = new Uint8Array([ 5, 10, 15, 20 ]);
const C = new Uint8Array([ 0, 2, 4, 6,, 8, 10 ]);
const D = new Uint8Array([ 1, 3, 5, 7, 9 ]);
  
// Calling include() function
a = A.includes(6)
b = B.includes(21, 1)
c = C.includes(6, 4)
d = D.includes(0)
  
// Printing true or false, either the element
// is present in the typedArray or not
console.log(a);
console.log(b);
console.log(c);
console.log(d);
 
 

Output:

false  false  false  false


Next Article
JavaScript typedArray.indexOf() Method

K

Kanchan_Ray
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • JavaScript-Methods
  • javascript-typedArray

Similar Reads

  • JavaScript typedArray.indexOf() Method
    The typedArray.indexOf() is an inbuilt function in JavaScript which is used to return the index of the element if found in the given typedArray otherwise it returns -1. Syntax: typedarray.indexOf(Element, Index); Parameters: It accepts two parameter which are specified below- Element: It is the elem
    2 min read
  • JavaScript TypedArray.prototype.includes() Method
    In JavaScript the TypedArray.prototype.includes() method is used to check that the given typed array contains a specific given element or not, if it contains the element it returns true otherwise false. SyntaxtypedArray.includes(searchElement)ORtypedArray.includes(searchElement, fromIndex)Parameters
    1 min read
  • JavaScript String includes() Method
    The includes() method returns true if a string contains a specified string. Otherwise, it returns false. Note: The includes() method is case sensitive i.e. it will treat the Uppercase Characters and Lowercase Characters differently. Syntax:string.includes(searchvalue, start)Parameters:search value:
    3 min read
  • JavaScript typedArray.of() Method
    The typedArray.of() is an inbuilt function in JavaScript which is used to construct a new typedArray with a variable number of parameters. Syntax: TypedArray.of(element0, element1, ......) Parameters: It accepts parameters of different elements whose typedArray is going to be created. Return value:
    1 min read
  • JavaScript typedArray.set() Method
    The typedArray.set() is an inbuilt function in JavaScript which is used to stores a number of values in the given typedArray. typedArray.set(typedArray, offset) Parameters: It accept two parameters which are specified below- typedarray: It is the source array. offset: It is optional and it is into t
    1 min read
  • JavaScript typedArray.some() Method
    The typedArray.some() is an inbuilt function in JavaScript which is used to check whether some elements of the typedArray satisfy the test implemented by the given function. Syntax: typedarray.some(callback) Parameters: It takes the parameter callback function and this callback function takes three
    2 min read
  • JavaScript typedArray.length() Method
    The typedArray.length is an inbuilt property in JavaScript which is used to return the length of the given typedArray. Syntax: typedArray.length Parameters: It does not accept any parameter because it is a property not a function. Return value: It returns the length of the given typedArray. Example
    2 min read
  • JavaScript Array includes() Method
    The includes() method in JavaScript returns true if an array contains a specified value, and false if the value is not found. This method simplifies checking for the presence of an element within an array, offering a quick and efficient way to return a boolean result. Syntaxarray.includes(searchElem
    3 min read
  • JavaScript typedArray.from() Property
    The typedArray.from() is an inbuilt function in JavaScript which is used to construct a new typedArray from a normal array or any iterable object. List of different typedArrays are specified in the table below: Int8Array();Int16Array();Uint32Array();Uint8Array();Uint16Array();Float32Array();Uint8Cla
    2 min read
  • JavaScript typedArray.@@species with Example
    The typedArray.@@species is an inbuilt property in JavaScript that is used to return the constructor of the given typedArray. The typedArray is of many types like: Int8Array();Int16Array();Uint32Array();Uint8Array();Uint16Array();Float32Array();Uint8ClampedArray();Int32Array();Float64Array(); Syntax
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences