Web Programming and Scripting
What this domain tests
Client-side logic: JavaScript basics, the DOM, events, form validation, and the security boundaries between browser and server.
Core rules and concepts
- Client code runs in the browser; server code runs on the host. Anything in the browser can be read and changed, so validation there is convenience, not security.
- Declare with
constby default andletwhen reassignment is needed; avoidvar. Know strings, numbers, booleans, arrays and objects. - DOM:
querySelector,textContent,classList,setAttribute,addEventListener. PrefertextContentoverinnerHTMLfor user data to prevent cross-site scripting. - Events: click, submit, input, keydown. Call
preventDefault()when handling a form yourself. - HTTP methods: GET retrieves, POST submits; status codes 200 OK, 301 moved, 404 not found, 500 server error.
- Storage: cookies,
localStorageandsessionStorage; respect the same-origin policy.
Worked example
Validate an email field on submit. Reasoning: listen for submit, call preventDefault(), read the value, test it with a simple pattern, and if invalid write a message into an element with aria-live="polite" and move focus to the field. If valid, allow submission. The same check must be repeated on the server, because a user can disable scripts entirely.
Traps that cost marks
Relying only on client validation; inserting user input with innerHTML; using == where === is intended; blocking the page with long loops; forgetting that scripts may fail to load.