JavaScript Tutorial JavaScript Examples JQuery Tutorial CSS Tutorial HTML Tutorial About Us

Lesson 26: Creating Linear Search

JavaScript is an effective scripting language that can be used to perform search operations on the web. Of course, it has to work with server-side programming languages such as Java and CGI to be effective. However, you will learn simple search algorithm here using JavaScript.

In this lesson, we will learn how to write a script to perform a linear search for an array that consists of integers. We employ the If operator to compare the search value entered by the user and each number in the array. If the search value is equal to the number concern, it will return the position of that number in the array (which is actually the value of the subscript plus 1, as the subscript of the array starts with 0). we need to use the function parseInt to convert the value of the subscript into a numeric value so that it can perform arithmetic operation. We also use the logical operators for and if to perform the search operation.

To learn the details of linear search, we suggest you obtain a copy of JavaScript Made Easy Edition 2.

Preview the book

ISBN: 79-8636196570

Price: $20


Dear Friend, JavaScript Made Easy is an eBook written by the webmaster of our JavaScript Tutorial , Dr.Liew. It complements our free online tutorial by providing a complete tutorial for beginners. By reading this book ,you can:
  • Understand the basic concepts of JavaScript.
  • Create your own JavaScript Codes.
  • Get ideas from many interesting sample codes.
  • Modify the codes easily to suit your needs.
  • Learn how to implement JavaScript on your website.
You need PayPal account to order this E-book. If you don't have PayPal Account, get your PayPal account by clicking the banner below:
Sign up for PayPal and start accepting credit card payments instantly.

*Please wait for 10 seconds for PayPal to redirect you to E-book Download Page after ordering and making payment. Any problem please email:

Warmest Regards (Dr.Liew Voon Kiong)

❮ Previous Lesson Next Lesson ❯

Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy