The following warnings occurred:
Warning [2] Cannot modify header information - headers already sent by (output started at /home/likebdco/forums.likebd.com/inc/config.php:1) - Line: 5138 - File: inc/functions.php PHP 8.2.35 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 5138 header
/global.php 37 send_page_headers
/showthread.php 28 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/likebdco/forums.likebd.com/inc/config.php:1) - Line: 2327 - File: inc/functions.php PHP 8.2.35 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 2327 header
/inc/class_session.php 395 my_setcookie
/inc/class_session.php 116 session->load_guest
/global.php 49 session->init
/showthread.php 28 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/likebdco/forums.likebd.com/inc/config.php:1) - Line: 2327 - File: inc/functions.php PHP 8.2.35 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 2327 header
/inc/class_session.php 400 my_setcookie
/inc/class_session.php 116 session->load_guest
/global.php 49 session->init
/showthread.php 28 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/likebdco/forums.likebd.com/inc/config.php:1) - Line: 2327 - File: inc/functions.php PHP 8.2.35 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 2327 header
/inc/class_session.php 123 my_setcookie
/global.php 49 session->init
/showthread.php 28 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/likebdco/forums.likebd.com/inc/config.php:1) - Line: 2327 - File: inc/functions.php PHP 8.2.35 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 2327 header
/inc/functions.php 2396 my_setcookie
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 682 mark_thread_read
Warning [2] Cannot modify header information - headers already sent by (output started at /home/likebdco/forums.likebd.com/inc/config.php:1) - Line: 2327 - File: inc/functions.php PHP 8.2.35 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
[PHP] errorHandler->error_callback
/inc/functions.php 2327 header
/inc/functions.php 2396 my_setcookie
/inc/functions_indicators.php 255 my_set_array_cookie
/inc/functions_indicators.php 47 mark_forum_read
/showthread.php 682 mark_thread_read




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

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

Googleplus Pint
#1
জাভাস্ক্রিপ্টইন্টারনেটে ব্যবহৃত সবচেয়ে জনপ্রিয় স্ক্রিপ্টিং ল্যাংগুয়েজ। জাভাস্ক্রিপ্ট হল একটি ক্লায়েন্ট সাইড স্ক্রিপ্টিং ল্যাংগুয়েজ বা ব্রাউজার স্ক্রিপ্টিং। জাভাস্ক্রিপ্ট (কখনও কখনও সংক্ষিপ্ত JS) একটি প্রোটোটাইপ-ভিত্তিক স্ক্রিপ্টিং ল্যাংগুয়েজ যাতে পরিবর্তনশীল, দুর্বল টাইপ এবং প্রথম শ্রেণীর ফাংশন আছে। এটি একটি অবজেক্ট ওরিয়েন্টেড, কার্যকরী প্রোগ্রামিং শৈলী সমর্থনকারী। জাভাস্ক্রিপ্ট একটি ওবজেক্ট-ওরিয়েন্টেড, ডায়নামিক প্রোগ্রামিং ভাষা। এতে আছে ডেটা টাইপ, অপারেটর, গুরুত্বপূর্ণ কিছু অবজেক্ট (যেগুলো সব সময় আপনি ব্যবহার করতে পারবেন) আর ফাংশন বা মেথড। জাভা আর সি প্রোগ্রামিং ভাষা থেকে বেশ কিছু সিন্ট্যাক্স ধার করে নেওয়ায় যারা এসব ভাষায় পারদর্শী তাদের জন্য সুখবর । [৩]

ইতিহাস

১৯৯৫ সালে নেটস্কেপের প্রকৌশলী ব্রেন্ডন আইক জাভাস্ক্রিপ্ট তৈরি করেন, যেটা মুক্তি পায় ১৯৯৬ সালের শুরুর দিকে নেটস্কেপ ২ (ব্রাউজার) এর সাথে। এর নাম দেয়া হয়েছিল LiveScript, কিন্তু মার্কেটিং কৌশলের গ্যাড়াকলে পড়ে দুর্ভাগ্যজনত এর নাম জাভাস্ক্রিপ্ট হয়ে যায়, সান মাইক্রোসিস্টেম এর জাভা ল্যাংগুয়েজের জনপ্রিয়তাকে পুঁজি করার জন্য। জাভা আর জাভাস্ক্রিপ্টের মাঝে তেমন কোন মিল না থাকা সত্ত্বেও সেই থেকে তাই জাভাস্ক্রিপ্ট নামটা নিয়ে বিভ্রান্তি থেকে গেছে। মাইক্রোসফট এই প্রোগ্রামিং ভাষার সাথে প্রায় মিলে যায় এরকম একটি ল্যাংগুয়েজ JScript নাম দিয়ে প্রায় ৩ মাস পর ইন্টারনেট এক্সপ্লোরারের সাথে বাজারে নিয়ে আসে। এদিকে নেটস্কেপ Ecma International (স্ট্যান্ডার্ড নির্ধারণ করে এরকম একটি ইউরোপীয়ান সংস্থা) এর কাছে ল্যাংগুয়েজটি উপস্থাপন করে - যার ফলাফল ১৯৯৭ সালে ECMAScript এর প্রথম সংস্করণ হিসেবে বাজারে আসে। ১৯৯৯ সালে এই স্ট্যান্ডার্ডটি আরো উন্নত হয় ECMAScript সংস্করণ ৩ হিসেবে - আর সেই থেকে ভাষাটির তেমন কোন বড় পরিবর্তন হয়নি। চতুর্থ সংস্করণটি ভেস্তে যায়, ভাষাটির জটিলতা নিয়ে মতবিরোধের ফলাফল হিসেবে। তবে এই চতুর্থ সংস্করণের অনেক অংশবিশেষ কে ভিত্তি হিসেবে ধরে ২০০৯ সালে নতুন ECMAScript এর পঞ্চম সংস্করণ প্রকাশ করা হয়।[৪] when it was deployed in the Netscape Navigator 2.0 beta 3 in December.[৫]

ভাষার ধরন

সাধারন উদাহরণ
জাভাস্ক্রিপ্ট এ ভেরিয়েবল ডিক্লায়ার করা হয় var কি ওয়ার্ড দিয়ে :[৬]

var x; // defines the variable x and assigns to it the special value "undefined" (not to be confused with an undefined value)
var y = 2; // defines the variable y and assigns to it the value 2
এই ভাষায় কমেন্ট লিখা হয় ২টা স্ল্যাশ এর মাধ্যমে (//) । যেটা উপরে দেখতে পাচ্ছেন ।

এর কোন বিল্ড ইন ফাংশান নাই ; রান টাইম ইনভাইরন মেন্ট এটা প্রদান করে থাকে . The ECMAScript এর ৫ম এডিশনে বলা হয়েছে:[৭]

… এখানে কোন প্রভিশনের প্রয়োজন নাই । ডাটা স্ফেকিশনের জন্য .

যদিও অধিকাংশেরকনসল অবজেক্ট থাকে [৮] যা দ্বারা সে এর আউটপুট দেখতে পারে :

console.log("Hello World!");
জাভাস্ক্রিপ্ট এর একটা সিম্পল ফাংশন:

functionfactorial(n){if(n===0||n===1)return1;//fact0=fact1=1returnn*factorial(n-1)}factorial(3);// returns 6
একটা এনোনমাস ফাংশন :

functioncounter(){varcount=0;returnfunction(){return++count}};varclosure=counter();closure();// returns 1closure();// returns 2closure();// returns 3
[৯]

functionsum(){varx=0;for(vari=0;i<arguments.length;++i)x+=arguments[i];returnx}sum(1,2);// returns 3sum(1,2,3);// returns 6
varcounter=(function(){vari=0;// private propertyreturn{// public methodsget:function(){alert(i);},set:function(value){i=value;},increment:function(){alert(++i);}};})();// modulecounter.get();// shows 0counter.set(6);counter.increment();// shows 7counter.increment();// shows 8
আরো এডফান্সড উদাহরণ
এই সাধারন কোড জাভাস্ক্রিপ্ট এর বিভিন্য উদাহরণ প্রকাশ করে । .

/* Finds the lowest common multiple (LCM) of two numbers */functionLCMCalculator(x,y){// constructor functionvarcheckInt=function(x){// inner functionif(x%1!==0){thrownewTypeError(x+" is not an integer");// throw an exception}returnx;};this.a=checkInt(x)// semicolons ^^^^ are optional, a newline is enoughthis.b=checkInt(y);}// The prototype of object instances created by a constructor is// that constructor's "prototype" property.LCMCalculator.prototype={// object literalconstructor:LCMCalculator,// when reassigning a prototype, set the constructor property appropriatelygcd:function(){// method that calculates the greatest common divisor// Euclidean algorithm:vara=Math.abs(this.a),b=Math.abs(this.b),t;if(a<b){// swap variablest=b;b=a;a=t;}while(b!==0){t=b;b=a%b;a=t;}// Only need to calculate GCD once, so "redefine" this method.// (Actually not redefinition—it's defined on the instance itself,// so that this.gcd refers to this "redefinition" instead of LCMCalculator.prototype.gcd.// Note that this leads to a wrong result if the LCMCalculator object members "a" and/or "b" are altered afterwards.)// Also, 'gcd' === "gcd", this['gcd'] === this.gcdthis['gcd']=function(){returna;};returna;},// Object property names can be specified by strings delimited by double (") or single (') quotes.lcm:function(){// Variable names don't collide with object properties, e.g., |lcm| is not |this.lcm|.// not using |this.a*this.b| to avoid FP precision issuesvarlcm=this.a/this.gcd()*this.b;// Only need to calculate lcm once, so "redefine" this method.this.lcm=function(){returnlcm;};returnlcm;},toString:function(){return"LCMCalculator: a = "+this.a+", b = "+this.b;}};// একটা আউটপুট ফাংশন; এই প্রয়োগ সুধুমাত্র ওয়েব ব্রাওজারে কাজ করবে । functionoutput(x){document.body.appendChild(document.createTextNode(x));document.body.appendChild(document.createElement('br'));}// Note: Array's map() and forEach() are defined in JavaScript 1.6.// They are used here to demonstrate JavaScript's inherent functional nature.[[25,55],[21,56],[22,58],[28,56]].map(function(pair){// array literal + mapping functionreturnnewLCMCalculator(pair[0],pair[1]);}).sort((a,b)=>a.lcm()-b.lcm())// sort with this comparative function; => is a shorthand form of a function, called "arrow function".forEach(printResult);functionprintResult(obj){output(obj+", gcd = "+obj.gcd()+", lcm = "+obj.lcm());}
নিচের উদাহরনটা ওয়েব ব্রাউজারে প্রদর্শন করবে ।

LCMCalculator: a = 28, b = 56, gcd = 28, lcm = 56
LCMCalculator: a = 21, b = 56, gcd = 7, lcm = 168
LCMCalculator: a = 25, b = 55, gcd = 5, lcm = 275
LCMCalculator: a = 22, b = 58, gcd = 2, lcm = 638
Reply
#2
Oww Nice.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Code] তৈরি করুন javascript Random image লিংক bdyousufctg 1 4,245 02-07-2018, 08:34 PM
Last Post: Farhan
  এবার জাভা ফোনেও পিসির মতো Refresh ব্যবহার করুন,আর ফোনকে রাখুবন ফাস্ট Maghanath Das 0 3,210 02-19-2017, 07:11 PM
Last Post: Maghanath Das

Forum Jump:


Users browsing this thread: 1 Guest(s)