Zum Hauptinhalt springen
LIVE
CVSS 6.5CVE-2026-111315 | The Smaily Connect plugin for WordPress is vulnerable to Insecure Direct Object Reference in versions up to, and including, 3.24.0 This is due to the smaily_get_edit_user_id() function reading an attacker-controlled $_GET['user_id'] parameter without performing any ownership or capability check, and then feeding that id into smaily_get_userdata() (which calls get_user_meta()) when rendering the WooCommerce My Account 'edit-account' form via the smaily_print_CVSS 6.4CVE-2026-137713 | Webmin through 2.670 before ae8feb1 allows XSS via an SVG attachment in a mail queue, relevant if an authenticated user uploads an SVG document and an administrator views it.CVSS 6.9CVE-2026-137678 | A security vulnerability has been detected in code-projects Online Job Portal 1.0. Affected by this issue is some unknown functionality of the file Admin/InsertUser.php. Such manipulation of the argument txtUserName/txtPassword leads to sql injection. The attack can be launched remotely. The exploit has been disclosed publicly and may be used.CVSS 5.3CVE-2026-137703 | Flask-AppBuilder before 5.3.1 contains a path traversal vulnerability in ImageManager.save_file that allows authenticated users to write image files outside IMG_UPLOAD_FOLDER via unsanitized multipart filenames. Attackers with add or edit permission on a ModelView with an ImageColumn can upload filenames containing ../ segments to create or overwrite image files like static assets.CVSS 6.1CVE-2026-130039 | The LiteSpeed Cache plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'REQUEST_URI' parameter in all versions up to, and including, 7.9.3 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page. Successful exploitation requires comments to be open, a comment author name containinCVSS 6.1CVE-2026-136206 | The Export Products, Orders & Customers for WooCommerce plugin for WordPress is vulnerable to Reflected Cross-Site Scripting via the 'start_date' parameter in all versions up to, and including, 2.4.3 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that execute if they can successfully trick a user into performing an action such as clicking on a link. SucCVSS 9.4CVE-2026-137706 | Smart Portal developed by Direk Tech has a Missing Authorization vulnerability. Authenticated remote attackers can add a specified account to the Active Directory Domain Admins group, thereby obtaining domain administrator privileges.CVSS 8.7CVE-2026-137705 | Smart Portal developed by Direk Tech has an Arbitrary File Read vulnerability.Unauthenticated remote attackers can exploit Relative Path Traversal to download arbitrary system files.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Array Methods in JS - Part 2

JavaScript Array Search Methods What are Array Search Methods? Array Search Methods are used to: Find the position (index) of an element. Check whether an…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 6 Min. Lesezeit
Quelle: dev.to
Rubrik: Programmation sécurisée




JavaScript Array Search Methods






What are Array Search Methods?



Array Search Methods are used to:




  • Find the position (index) of an element.

  • Check whether an element exists.

  • Retrieve an element that satisfies a condition.

  • Find the index of an element that matches a condition.

  • Search from the beginning or the end of an array.






Common Array Search Methods
















































Method Purpose Returns
indexOf() Finds the first occurrence of a value Index or -1
lastIndexOf() Finds the last occurrence of a value Index or -1
includes() Checks whether a value exists
true / false
find() Finds the first matching element Element or undefined
findIndex() Finds the index of the first matching element Index or -1

findLast() (ES2023)
Finds the last matching element Element or undefined

findLastIndex() (ES2023)
Finds the last matching index Index or -1








1. Array.indexOf()






Definition



The indexOf() method searches an array for a specified value and returns the index of its first occurrence.



If the value is not found, it returns -1.









Syntax






array.indexOf(searchElement)

array.indexOf(searchElement, startIndex)












Parameters




















Parameter Description
searchElement Value to search for

startIndex (optional)
Index where the search starts








Returns




  • Index of the first matching element.


  • -1 if not found.









Internal Working



Suppose:




let fruits = ["Apple", "Orange", "Mango", "Orange"];






Memory:




Index

0 → Apple
1 → Orange
2 → Mango
3 → Orange






When:




fruits.indexOf("Orange");






JavaScript starts from index 0:




  • Apple ❌

  • Orange ✅ Found



Stops immediately and returns:




1












Example






let fruits = ["Apple", "Orange", "Banana"];

console.log(fruits.indexOf("Orange"));









Output






1












Example - Not Found






let fruits = ["Apple", "Orange"];

console.log(fruits.indexOf("Mango"));






Output




-1












Example - Start Position






let fruits = ["Apple", "Orange", "Banana", "Orange"];

console.log(fruits.indexOf("Orange", 2));






Output




3












Real-Time Example



Suppose an e-commerce site wants to know whether a product category exists.




let categories = ["Mobiles", "Laptops", "TV"];

let position = categories.indexOf("Laptops");

console.log(position);






Output




1












Time Complexity [TBD]




















Case Complexity
Best O(1)
Worst O(n)








Common Mistake






if (arr.indexOf("Apple"))






Wrong.



If Apple is at index 0, JavaScript treats 0 as false.



Correct:




if (arr.indexOf("Apple") !== -1)












Interview Questions



Q. What does indexOf() return if the value is not found?




-1












2. Array.lastIndexOf()






Definition



The lastIndexOf() method searches from the end of the array and returns the last matching index.









Syntax






array.lastIndexOf(searchElement)

array.lastIndexOf(searchElement, fromIndex)












Parameters




















Parameter Description
searchElement Value to search

fromIndex (optional)
Index to start searching backward








Returns



Last matching index or -1.









Internal Working






let colors = ["Red", "Blue", "Green", "Blue"];






Memory:




0 → Red
1 → Blue
2 → Green
3 → Blue






JavaScript starts from the last index:




  • Blue ✅



Returns:




3












Example






let colors = ["Red", "Blue", "Green", "Blue"];

console.log(colors.lastIndexOf("Blue"));






Output




3












Real-Time Example



Suppose a browser stores recently visited pages.




let history = ["Home", "Products", "Cart", "Products"];

console.log(history.lastIndexOf("Products"));






Output




3












Time Complexity



O(n)









Best Practice



Use lastIndexOf() when duplicate values exist and you need the most recent occurrence.









3. Array.includes()






Definition



The includes() method checks whether a value exists in an array.



It returns:




  • true

  • false



Unlike indexOf(), you don't have to compare with -1.









Syntax






array.includes(value)

array.includes(value, startIndex)












Parameters




















Parameter Description
value Value to search

startIndex (optional)
Starting position








Returns



Boolean









Internal Working



Suppose:




let skills = ["HTML", "CSS", "JavaScript"];






JavaScript compares each element.



If found:




true






Else:




false












Example






let skills = ["HTML", "CSS", "JavaScript"];

console.log(skills.includes("CSS"));






Output




true












Example






console.log(skills.includes("Python"));






Output




false












Real-Time Example



Netflix Premium Features




let features = ["4K", "HDR", "Offline Download"];

if (features.includes("HDR")) {
console.log("HDR Supported");
}






Output




HDR Supported












Time Complexity



O(n)









Common Mistake



Using:




indexOf() != -1






instead of




includes()






includes() is more readable when you only need to know whether the value exists.









Interview Question



Which is better?




includes()






or




indexOf()






Use:





  • includes() → existence check.


  • indexOf() → position required.









4. Array.find()






Definition



The find() method returns the first element that satisfies a given condition.



If no element matches, it returns undefined.









Syntax






array.find(callback)

array.find(callback, thisArg)












Callback Parameters






(element, index, array)



























Parameter Description
element Current element
index Current index
array Original array








Returns



Matching element or undefined.









Internal Working



Suppose:




let numbers = [10, 25, 30, 40];






Callback:




num > 20






JavaScript checks:




10 ❌
25 ✅






Stops immediately.



Returns:




25












Example






let numbers = [10, 25, 30, 40];

let result = numbers.find(num => num > 20);

console.log(result);






Output




25












Real-Time Example



Find the first student who scored above 90.




let marks = [65, 72, 95, 88];

let topper = marks.find(mark => mark > 90);

console.log(topper);






Output




95












Time Complexity



O(n)









Common Mistake



find() returns the element, not its index.









Interview Question



Difference between find() and filter()?





  • find() → first matching element.


  • filter() → all matching elements.









5. Array.findIndex()






Definition



Returns the index of the first element satisfying the condition.



If not found:




-1












Syntax






array.findIndex(callback)












Example






let ages = [15, 18, 25, 40];

console.log(ages.findIndex(age => age >= 18));






Output




1












Real-Time Example



Locate the first pending order.




let orders = [
{ id: 1, status: "Completed" },
{ id: 2, status: "Pending" },
{ id: 3, status: "Pending" }
];

let index = orders.findIndex(order => order.status === "Pending");

console.log(index);






Output




1












Time Complexity



O(n)









6. Array.findLast() (ES2023)






Definition



Returns the last element that satisfies a condition.









Syntax






array.findLast(callback)












Example






let numbers = [12, 18, 25, 30];

let result = numbers.findLast(num => num > 20);

console.log(result);






Output




30












Real-Time Example



Find the latest completed transaction.




let transactions = [
{ id: 1, status: "Pending" },
{ id: 2, status: "Completed" },
{ id: 3, status: "Completed" }
];

let latest = transactions.findLast(t => t.status === "Completed");

console.log(latest);






Output




{ id: 3, status: "Completed" }












Time Complexity



O(n)









7. Array.findLastIndex() (ES2023)






Definition



Returns the index of the last matching element.









Syntax






array.findLastIndex(callback)












Example






let numbers = [5, 15, 25, 35];

console.log(numbers.findLastIndex(num => num > 20));






Output




3












Real-Time Example



Find the index of the last product that is out of stock.




let products = [
{ name: "Laptop", stock: 5 },
{ name: "Mouse", stock: 0 },
{ name: "Keyboard", stock: 10 },
{ name: "Monitor", stock: 0 }
];

let index = products.findLastIndex(product => product.stock === 0);

console.log(index);






Output




3












Time Complexity



O(n)









Summary Comparison
































































Method Returns Search Direction Callback Required Modifies Array
indexOf() First matching index Left → Right ❌ ❌
lastIndexOf() Last matching index Right → Left ❌ ❌
includes()
true / false
Left → Right ❌ ❌
find() First matching element Left → Right ✅ ❌
findIndex() First matching index Left → Right ✅ ❌
findLast() Last matching element Right → Left ✅ ❌
findLastIndex() Last matching index Right → Left ✅ ❌





Tips




  • Use includes() when you only need to check if a value exists.

  • Use indexOf() or lastIndexOf() when you need the position of a primitive value.

  • Use find() or findIndex() for arrays of objects or custom conditions.

  • Use findLast() and findLastIndex() (ES2023) when you need to search from the end without reversing the array.

  • Remember that indexOf() and includes() use strict equality (===) for comparison, so searching for objects compares references, not object contents.



References:

https://www.w3schools.com/js/js_array_search.asp

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Discussion communautaire et commentaires

🌐 Rejoindre le chat principal

Lancez la discussion dans le flux diffusé du Social Chat ou proposez ci-dessus une contribution experte via le formulaire de complément.

Évaluation communautaire & preuve sociale
⭐ Avis des lecteurs
–
Ø / 5.0
Pas encore d'évaluation des lecteurs
Cet article vous a-t-il été utile ?
0
Donner votre évaluation
Évaluation détaillée (facultatif)
Contenu & qualité
Source & fiabilité
Actualité
Briefing sécurité Gratuit · désabonnement en 1 clic

Intelligence Digest — gratuit

Chaque jour, les principales actualités sécurité · résiliable à tout moment

Groupes d’histoires apparentées & sources (IA vectorielle)

6 Cluster
44 sources
Best Black Friday home office deals 2026 — save on our top-tested work essentials from Herman Miller, FlexiSpot, Logitech, Epson and more
Latest from TechRadar il y a 27 min.
43 autres sources
Latest from TechRadaril y a 26 min.Sony WH-1000XM6 just hit a record-low price — now it's Black Friday Latest from TechRadaril y a 21 min.Lenovo's Copilot+ IdeaPad Slim 3 with 16GB RAM and a 512GB SSD is £350 off for Black Friday The Vergeil y a 16 min.Our favorite headphones and earbuds are cheaper than ever ahead of Black Friday Computer Bildil y a 30 min.Black Friday: Live-Show ab 16 Uhr – die besten Deals t3n.deil y a 30 min.Black Friday: Alle guten Angebote zu Apple, Samsung, Fritz und Co. in der Übersicht Golem.deil y a 22 min.Anzeige: Google Pixel 10a am Black Friday bei Amazon erstmals unter 380 Euro COMPUTER BILDil y a 1 hCOMPUTER BILD: Die Deal-Checker! BLACK FRIDAY 2026 WIREDil y a 41 min.The Best Black Friday Streaming Deals (2026): Apple TV, Disney, Paramount, and More GamingOnLinux Latest Articl…il y a 48 min.itch.io Creator Day & Black Friday 2026 sale is live Latest from TechRadaril y a 56 min.Best Black Friday MacBook Air deals: biggest discounts on Apple's thin and light laptop range Latest from TechRadaril y a 46 min.Proton VPN vs ExpressVPN – which secure VPN should you pick this Black Friday? WIREDil y a 9 hThe 108 Best Black Friday Deals Are Now Live: Our Expert Picks for 2026 WIREDil y a 52 min.20 Best Black Friday Tech Deals (2026) WIREDil y a 51 min.The 10 Best Black Friday TV Deals (2026): Save Up to 53% Off Giga.deil y a 42 min.Black Friday 2026 bei Back Market: Dyson, Ninja und GoPro jetzt deutlich günstiger Cyber Security Newsil y a 1 hBlack Friday or Black Fraud Day? 7 Cyber Traps to Watch Out for Before You Click ‘Buy’ CNETil y a 2 joursLive: Black Friday Is Here. Shop Our Favorite Deals and Save Up to 60% Apple, Anker, Bose and More WIREDil y a 1 h22 Best Black Friday Deals Under $100 (2026) WIREDil y a 1 hBest Black Friday Phone Deals (2026): iPhone, Pixel, and More The Vergeil y a 1 hThe absolute best Black Friday deals we’ve found (so far) Giga.deil y a 1 hAirPods Pro 3 im Black-Friday-Sturzflug: So günstig waren Apples Top-In-Ears noch nie PC-WELTil y a 1 hBlack Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr PC-WELTil y a 1 hBlack Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr t3n.deil y a 1 hKindle, Echo Dot, Fire TV: Diese neuen Amazon-Geräte sind zum Black Friday stark reduziert Macerkopf.deil y a 1 hAmazon Black Friday Woche: iPad Air, iPhone 18 Cases, AirTag 2, Fire TV Sticks, Echo Dot und mehr appgefahren.deil y a 1 hJMGO mit Black Friday-Deals: Heimkino-Bundles bis zu 60 Prozent günstiger PC-WELTil y a 1 hGoogle Pixel 11 jetzt unglaubliche 430 Euro günstiger im Black-Friday-Deal: Tiefstpreis bei Amazon PC-WELTil y a 1 hNorton 360 Premium-Security an Black Friday nur 19,99 Euro statt 100 Euro Latest from TechRadaril y a 1 hThe best Black Friday headphone deals: Sony, AirPods and more Latest from TechRadaril y a 1 hBest Black Friday mini PC deals 2026 live: Save on desktops from Apple, Geekom, GMKtec, Minisforum, and more Golem.deil y a 1 hAnzeige: Amazon startet mit Glücksrad-Gewinnspiel in den Black Friday Latest from TechRadaril y a 1 hThese smart and polished backpacks have accompanied me to events all over the world — and they're now 30% for Black Friday PC-WELTil y a 1 hRiesiger 75 Zoll 4K-QLED-Fernseher fällt bei Amazon auf nur 469 Eur im Black-Friday-Angebot PC-WELTil y a 1 hBlack Friday: Beliebte Mähroboter von Mammotion jetzt ab 599 Euro Latest from TechRadaril y a 2 hSave up to around £200 on these top mini PCs for Black Friday — with multiple options and configurations available for your exact needs or preferences Caschys Blogil y a 3 hFlexiSpot Black Friday 2026: Bis zu 40 % Rabatt auf Bestseller bei Amazon Golem.deil y a 1 hBlack Friday: Verdi mobilisiert bei Amazon in Gera nur wenige PC-WELTil y a 2 hNotebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro appgefahren.deil y a 2 htink.de bietet bis zu 50 Euro Extra-Rabatt auf Black-Friday-Angebote PC-WELTil y a 2 hNotebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro Latest from TechRadaril y a 2 hWhich all-in-one Black Friday VPN bundle is really worth it? I compared NordVPN Prime, ExpressVPN Pro, and Proton Unlimited — all under $7 a month — to decide PC-WELTil y a 2 hAmazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro PC-WELTil y a 2 hAmazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro
22 sources
CVE-2026-95457 | Google Android Camera reconnect.shard.cml privileges management
VulDB Updates il y a 52 min.
21 autres sources
VulDB Updatesil y a 52 min.CVE-2026-95458 | Google Android Bluetooth Setup bluetooth_setup_impl.cc OnAudioSourceConnectChanged privileges management VulDB Updatesil y a 52 min.CVE-2026-95464 | Google Android logical_link.cc SignalError use after free VulDB Updatesil y a 52 min.CVE-2026-95456 | Google Android a2dp_offload_manager.cc StartA2dpOffload use after free VulDB Updatesil y a 52 min.CVE-2026-95463 | Google Android data_element.cc DataElement::Read recursion Engadgetil y a 1 hGoogle will soon share Android developers' addresses publicly VulDB Updatesil y a 1 hCVE-2026-95429 | Google Android BrEdrDynamicChannel bredr_dynamic_channel.cc resource consumption VulDB Updatesil y a 1 hCVE-2026-95434 | Google Android LowEnergyScanner low_energy_scanner.cc NotifyPeerFound resource consumption VulDB Updatesil y a 1 hCVE-2026-95441 | Google Android Bluetooth connection.cc OnDisconnectionComplete denial of service VulDB Updatesil y a 1 hCVE-2026-95422 | Google Android periodic_advertising_synchronizer.cc OnSyncEstablished assertion VulDB Updatesil y a 1 hCVE-2026-95423 | Google Android local_service_manager.cc OnWriteCCC null pointer dereference VulDB Updatesil y a 1 hCVE-2026-95447 | Google Android SDP Client client.cc OnRxFrame memory corruption VulDB Updatesil y a 1 hCVE-2026-95421 | Google Android Command Processing bredr_signaling_channel.cc DecodeRxUnit use after free VulDB Updatesil y a 1 hCVE-2026-95435 | Google Android advertising_data.cc FromBytes out-of-bounds VulDB Updatesil y a 1 hCVE-2026-95446 | Google Android credit_based_flow_control_rx_engine.cc ProcessPdu input validation VulDB Updatesil y a 1 hCVE-2026-95420 | Google Android Pairing security_manager.cc OnEncryptionChange privileges management VulDB Updatesil y a 1 hCVE-2026-95419 | Google Android Bluetooth Security Manager security_manager.cc OnPairingRequest unusual condition VulDB Updatesil y a 1 hCVE-2026-95416 | Google Android Link Encryption Key security_manager.cc OnPairingFailed denial of service VulDB Updatesil y a 1 hCVE-2026-95415 | Google Android RemoteCharacteristic remote_characteristic.cc denial of service VulDB Updatesil y a 1 hCVE-2026-95417 | Google Android remote_characteristic.cc ResolvePendingNotifyRequests use after free VulDB Updatesil y a 1 hCVE-2026-95414 | Google Android http_file_request_handler.cc GetFilePath path traversal VulDB Updatesil y a 1 hCVE-2026-95418 | Google Android logical_link.cc LogicalLink::SignalError use after free
Articles similaires
🔍 Verwandte News

Auch interessante Nachrichten Array Methods in JS - Part 2

Thematisch verwandte Begriffe: Array, Methods, Part · 6 Treffer

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

💬 Chargement des commentaires…
Sentinel CTI: ONLINE
Tirer pour actualiser
Widgets & Topics
Loading widgets…
Nächster Beitrag