Skip to main content

Command Palette

Search for a command to run...

JavaScript වල scope තේරුම් ගන්නේ මෙහෙමයි

Updated
2 min readView as Markdown
JavaScript වල scope තේරුම් ගන්නේ මෙහෙමයි
H

QA Engineer | Selenium, Playwright, Postman, JMeter | API/UI Testing | Manual & Automation | MERN Stack | ISTQB Trainee | QA Blogger

ඔයාලා දන්නවා ඇති javascript කියන්නේ අද ලෝකේ බහුලවම බාවිතා වෙන progamming lanuage එකක්. මම මේ ආර්ටිකල් එකෙන් කතා කරන්නේ ජාවාස්ක්‍රිප්ට් Variables ගැන හා scopes ගැන.javascipt වල variables හදාගන්න පුලවන් ක්‍රම 03ක් තියනෙවා.

1. Using the keyword Var

2. Using the keyword Let

3. Using the keyword Const

මේ තුනන් අද මන් කතා කරන්නේ 1නි ක්‍රමය ගැන ( Using the keyword Var)

JavaScript වල Var තේරුම් ගන්නේ මෙහෙමයි

අපි var එකක් global scope එකේ declare කරලා define කලාම ඒ සදහා memory space එකක් globally create වෙලා අදාළ value එක assign වෙනවා.

ඒ වගේම තමා function එකක් ඇතුලේ var එකක් declare කරලා define කලාම ඒ සදහා memory space එකක් function scope එක ඇතුලේ create වෙනවා.

ඔයාල දන්නවා දැන් var කියන්නේ global scope කියලා නමුත් var Function scope එක ඇතුලෙත් අනිවරෙන් වැඩ කරනවා.

කොමද එහෙම වෙන්නේ එකට හේතුව තමා var වලින් variable එකක් declare එක කෙලින්ම window object එකේ property එකක් වෙනවා.මෙන්න මේ හේතුව හින්ද තමා javascript වල var function scope එකක් ඇතුලේ වැඩ කරන්නේ.window object කියන්නේ browser object hirachey එකේ උඩින්ම ඉන්නේ window object.(window object model ගැන අපි වෙන article එකකදී කතා කරමු)

මේක නිකන් ඔය කොචියේ යද්දී 1st ක්ලස් ටිකට් එකක් අරන් කැමති නම් 3rd ක්ලස් එකේ යන්න පුලවන් නේ.අන්න ඒ වගේ වැඩක් තමා මෙතන වෙන්නේ var කියන එක ග්ලෝබල් scope උනාට එයා function scope එක ඇතුලෙත් වැඩ කරනවා.

පොඩ්ඩක් කන්ෆුසින්ග් වගේ ඇති ගනන් ගන්න එපා javascrpit කොමත් බිලා වගේ තමා ඉන්නේ.හැබයි js හොද මිටරෙන් ඉන්නේ මන් එහම කියන්නේ මොකද කියලා ඉලග අටිකල් එකෙන් කථ කරන්නම්.

මීලග article එකෙන් අපි “let” key word එකෙන් declare කරපු JavaScript variables ගැන සොයා බලමු.

Thank you for reading, and let's connect!

Thank you again for your support and for being a part of this community. Feel free to connect with me on Facebook or Linkedin

More from this blog

How to Begin API Automation: From Postman to Newman

අද මම කතා කරන්න යන්නේ ජනප්‍රිය API Testing tool එකක් වෙන Postman ගැන.හැබැයි අද මගේ Main Topic එක Postman ගැන නෙවෙයි — ඒකේ සහෝදරයා, කියලා කියන්න පුළුවන් Newman ගැන. Postman සහ Newman දෙන්න අතර වෙනස හිතන්න මෙහෙම Postman = Manual testing tool Newman =...

Oct 13, 20254 min read
How to Begin API Automation: From Postman to Newman

📌 Schema Validation කියන්නේ මොකක්ද?

Schema කියන්නේ basically blueprint එකක් for your data.ඒ කියන්නේ, API එකෙන් එන data එකේ ආකාරය, format එක, මොකක්ද කියලා define කරන එක.API එකක් test කරනකොට, data එක පමණක් නොව, එය data එන structure එකත් බලන්න ඕන. මේකට Schema Validation කියල කියනවා 🔎 උදා...

Sep 10, 20252 min read
📌 Schema Validation කියන්නේ මොකක්ද?

Dev Diaries By Hasanka

17 posts

QA Engineer | Selenium, Playwright, Postman, JMeter | API/UI Testing | Manual & Automation | MERN Stack | ISTQB Trainee | QA Blogger