Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

ভূমিকা

এই অধ্যায়টি জাভাস্ক্রিপ্ট-এর পরিচয় এবং এর প্রাথমিক ধারনা নিয়ে আলোচনা করা হয়েছে।

আপনাকে আগে থেকেই কি জানতে হবে?

এই গাইডটি ভালভাবে বুঝার জন্য নিচের এই সাধারণ জ্ঞান থাকা একান্ত প্রয়োজনীয়ঃ

  • ইন্টারনেট এবং ওয়ার্ল্ড ওয়াইড ওয়েব সম্পর্কে সাধারণ ধারনা (WWW).
  • হাইপার টেক্সট মার্কআপ লেঙ্গুয়েজ এ কাজ করার ভাল জ্ঞান (HTML).
  • কিছু প্রোগ্রামীং দক্ষতা। যদি আপনি প্রোগ্রামিং এ নতুন হয়ে থাকেন, তাহলে প্রধান পাতায় জাভাস্ক্রিপ্ট সম্পর্কে টিউটরিয়ালগুলি থেকে যে কোন একটি চেষ্টা করুন।

কোথায় জাভাস্ক্রিপ্ট সম্পর্কে তথ্য খুজে পাবেন?

এমডিএন এর জাভাস্ক্রিপ্টের ডকুমেন্টেশান নিচের গুলি সহঃ

  • Learning the Web provides information for beginners and introduces basic concepts of programming and the Internet.
  • JavaScript Guide (this guide) provides an overview about the JavaScript language and its objects.
  • JavaScript Reference provides detailed reference material for JavaScript.

If you are new to JavaScript, start with the articles in the learning area and the JavaScript Guide. Once you have a firm grasp of the fundamentals, you can use the JavaScript Reference to get more details on individual objects and statements.

জাভাস্ক্রিপ্ট কি?

JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment, JavaScript can be connected to the objects of its environment to provide programmatic control over them.

JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects; for example:

  • Client-side JavaScript extends the core language by supplying objects to control a browser and its Document Object Model (DOM). For example, client-side extensions allow an application to place elements on an HTML form and respond to user events such as mouse clicks, form input, and page navigation.
  • Server-side JavaScript extends the core language by supplying objects relevant to running JavaScript on a server. For example, server-side extensions allow an application to communicate with a database, provide continuity of information from one invocation to another of the application, or perform file manipulations on a server.

জাভাস্ক্রিপ্ট এবং জাভা

JavaScript and Java are similar in some ways but fundamentally different in some others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.

In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.

JavaScript is a very free-form language compared to Java. You do not have to declare all variables, classes, and methods. You do not have to be concerned with whether methods are public, private, or protected, and you do not have to implement interfaces. Variables, parameters, and function return types are not explicitly typed.

Java is a class-based programming language designed for fast execution and type safety. Type safety means, for instance, that you can't cast a Java integer into an object reference or access private memory by corrupting Java bytecodes. Java's class-based model means that programs consist exclusively of classes and their methods. Java's class inheritance and strong typing generally require tightly coupled object hierarchies. These requirements make Java programming more complex than JavaScript programming.

In contrast, JavaScript descends in spirit from a line of smaller, dynamically typed languages such as HyperTalk and dBASE. These scripting languages offer programming tools to a much wider audience because of their easier syntax, specialized built-in functionality, and minimal requirements for object creation.

জাভার সাথে তুলনায় জাভাস্ক্রিপ্ট
জাভাস্ক্রিপ্ট জাভা
Object-oriented. No distinction between types of objects. Inheritance is through the prototype mechanism, and properties and methods can be added to any object dynamically. Class-based. Objects are divided into classes and instances with all inheritance through the class hierarchy. Classes and instances cannot have properties or methods added dynamically.
Variable data types are not declared (dynamic typing). Variable data types must be declared (static typing).
Cannot automatically write to hard disk. Can automatically write to hard disk.

For more information on the differences between JavaScript and Java, see the chapter Details of the object model.

জাভাস্ক্রিপ্ট এবং ইসিএমএস্ক্রিপের বিবরণ

JavaScript is standardized at Ecma International — the European association for standardizing information and communication systems (ECMA was formerly an acronym for the European Computer Manufacturers Association) to deliver a standardized, international programming language based on JavaScript. This standardized version of JavaScript, called ECMAScript, behaves the same way in all applications that support the standard. Companies can use the open standard language to develop their implementation of JavaScript. The ECMAScript standard is documented in the ECMA-262 specification. See New in JavaScript to learn more about different versions of JavaScript and ECMAScript specification editions.

The ECMA-262 standard is also approved by the ISO (International Organization for Standardization) as ISO-16262. You can also find the specification on the Ecma International website. The ECMAScript specification does not describe the Document Object Model (DOM), which is standardized by the World Wide Web Consortium (W3C). The DOM defines the way in which HTML document objects are exposed to your script. To get a better idea about the different technologies that are used when programming with JavaScript, consult the article JavaScript technologies overview.

জাভাস্ক্রিপ্টের ডকুমেন্টেশান বনাম ইসিএমএস্ক্রিপের বিবরণ

The ECMAScript specification is a set of requirements for implementing ECMAScript; it is useful if you want to implement standards-compliant language features in your ECMAScript implementation or engine (such as SpiderMonkey in Firefox, or v8 in Chrome).

The ECMAScript document is not intended to help script programmers; use the JavaScript documentation for information on writing scripts.

The ECMAScript specification uses terminology and syntax that may be unfamiliar to a JavaScript programmer. Although the description of the language may differ in ECMAScript, the language itself remains the same. JavaScript supports all functionality outlined in the ECMAScript specification.

The JavaScript documentation describes aspects of the language that are appropriate for a JavaScript programmer.

জাভাস্ক্রিপ্ট নিয়ে শুরু করা যাক

Getting started with JavaScript is easy: all you need is a modern Web browser. This guide includes some JavaScript features which are only currently available in the latest versions of Firefox, so using the most recent version of Firefox is recommended.

There are two tools built into Firefox that are useful for experimenting with JavaScript: the Web Console and Scratchpad.

ওয়েব কনসল

The Web Console shows you information about the currently loaded Web page, and also includes a command line that you can use to execute JavaScript expressions in the current page.

To open the Web Console, select "Web Console" from the "Web Developer" menu, which is under the "Tools" menu in Firefox. It appears at the bottom of the browser window. Along the bottom of the console is a command line that you can use to enter JavaScript, and the output appears in the pane above:

স্ক্রেচপেড

The Web Console is great for executing single lines of JavaScript, but although you can execute multiple lines, it's not very convenient for that, and you can't save your code samples using the Web Console. So for more complex examples Scratchpad is a better tool.

স্ক্রেচপেড খুলতে, "Web Developer" মেনু থেকে "Scratchpad" বাচাই করুন, যা ফায়ারফক্সের "Tools" মেনুর মধ্যে আছে। এইটা একটা ভিন্ন উইন্ডোতে খুলবে এবং এইটা একটা সম্পাদনাকারি যা আপনি ব্রাউজারে জাভাস্ক্রিপ্ট লিখতে এবং সম্পাদন করতে ব্যবহার করতে পাড়বেন। আপনি আরো পারবেন ডিস্কে স্ক্রিপগুলি সংরক্ষন করতে এবং ডিস্ক থেকে লোড করতে।

যদি আপনি "Inspect" নির্বাচন করেন, আপনার পেডের কোডটি ব্রাউজারে সম্পাদন করবে এবং ফলাফলটি ফিরে এসে আপনার পেডে কমেন্ট হিসেবে স্থাপন হবেঃ

হ্যাল্লো ওয়ার্ল্ড

জাভাস্ক্রিপ্ট লেখা শুরু করতে, ওয়েব কনসল বা স্ক্রেচপেড খুলুন এবং আপনার প্রথম "হ্যাল্লো ওয়ার্ল্ড" জাভাস্ক্রিপ্ট কোড লিখুন।

function greetMe(user) {
  return "Hi " + user;
}

greetMe("Alice"); // "Hi Alice"

এইপেজগুলিতে, গাউডটি জাভাস্ক্রিপ্ট সিনটেক্স এবং ল্যাঙ্গুয়েজের সবিধাসমূহ পরিচিত করবে, তখন আপনি আরো জটিল অ্যাপ্লিকেশানগুলি লিখতে পারবেন।

ডকুমেন্ট ট্যাগ এবং অবদানকারী

 Contributors to this page: itskawsar
 সর্বশেষ হালনাগাদ করেছেন: itskawsar,