How Do You Find the JQuery Version from the Command Prompt of a Linux Server?

Problem scenario
You are using Linux, and you want to know what JQuery version is installed. What do you do?

Solution
JQuery is a library to work with Javascript. There are many ways to install JQuery: git, using a .tar.gz file, the YARN CLI, or the npm command.

If it was installed with npm, one way find out the version is to run one of these command:

npm view jquery versions
npm view jquery version
npm view jquery
npm info jquery
npm ls jquery

This solution was partially taken from this external page.

How Do You Get a Table in HTML/Javascript to Display Only The First n (or 10) Rows?

Problem scenario
You have a web page with a table. It uses HTML and Javascript. You want only a sub-portion of the rows to be displayed and allow the user from the front-end to click a drop down menu to see more results. What should you do?

Possible Solution #1
Have two blocks in the .html file. Have the top one define a function that accepts a parameter and filters the table results if/when called.

What Are Some Ways to Prevent MITM Attacks or Other Session Exploitative Attacks with a Web Page That Uses JavaScript?

Problem scenario
You know that sessions of a JavaScript can be exploited in today’s world. This category of vulnerability is related to imperfections in authentication and is listed as the #2 biggest web application security risk as of June of 2020 (according to OWASP). What are some techniques to stop such attacks from happening when designing a website that uses JavaScript?

Possible Solution #1
Ensure cookie information is passed using connections that leverage HTTPS (as paraphrased from page 23 of Node.js Security by Liran Tal).

What Are Some Ways to Prevent XSS Attacks with a Web Page That Uses JavaScript?

Problem scenario
You know that cross-site scripting (aka XSS) attacks are a big concern in today’s world. OWASP places XSS security risks as the seventh biggest web application risk as of June 2020. What are some techniques to stop such attacks from happening when designing a website that uses JavaScript?

Possible Solution #1
Have the HTML and JavaScript validate and escape regularly throughout the code.

How Do You Assign a Variable in JavaScript from User Input?

Problem scenario
You want to read input and assign it as a variable in JavaScript. What should you do?

Solution
Create a .html file, saved directly on your desktop or in a /var/www/html/ directory on a web server, with the follow content to illustrate how to do this (then open it in a web browser):

<!DOCTYPE html<html<body<h2Use JavaScript to Change Text</h2<pThis example writes “Hello in JavaScript from Continualintegration.com!” into an HTML element with id=”demo”:</p<p id=”demo”</p<scriptvar foo = prompt(“Please enter input and press enter”); …

How Do You Use Multi-Line String Variables in JavaScript?

Problem scenario
You want to present multiple lines in an “alert” message in JavaScript. How do you have new lines with text in JavaScript?

Possible Solution #1 (less preferred)
Use syntax like this:

var y = `
line1
line2
line3
`;

Possible Solution #2 (preferred)

var z = [
line1,
line2,
line3
].join(“\n”);

You could use this stand-alone file multiline.html:

<!DOCTYPE html<html<body<h2This demonstrates a multi-line variable in JavaScript</h2<p id=”demo”</p<scriptline1 = “aaa”
line2 = “bbb”
line3 = “ccc”

var z = [
line1, …

How Do You Create a Function in JavaScript?

Problem scenario
You want to create a function in JavaScript. This way you can use code over-and-over. How do you use a function in JavaScript?

Solution
Call this file contint.html

<!DOCTYPE html<html<body<h2This demonstrates accepting input and using a function in JavaScript</h2<p id=”demo”</p<scriptx = 5
var foo = prompt(“Please enter a number”);

function contintFunction(p1, …

How Do You Get JavaScript to Present in a Web Browser?

Problem scenario
You have a .js file on your desktop or on a web server. You want to have the code execute and present itself nicely (not just see the raw code) in a web browser. How do you do this?

Solution
You must use the .html extension. You must have

<html</html

tags. Here is an example. Name this file contint.html and place it on your desktop,

How Do You Troubleshoot the ng Error “—–Mg: scratch (fundamental)—-All——————“?

Problem scenario
You run this command ng –version, but you receive a blank screen at the terminal like this:

—–Mg: scratch (fundamental)—-All——————

What do you do?

Solution

1. Use “ctrl-z” to exit out.

2. Run these commands:

sudo apt remove ng-common
sudo npm uninstall -g @angular/cli
sudo npm install -g @angular/cli

3.