Public Questions for tag [javascript]

Ask Question

JavaScript is the world's most popular programming language of the Web and very easy to learn. JavaScript is a very lightweight, explained, and just-in-time compiled programming language. JavaScript is supporting object-oriented, explained, and declarative styles. JavaScript is a prototype-based, multi-paradigm, single-threaded, and dynamic language.

52 questions


0

Vote

1

Answers

11

View

How to select table cells vertically and horizontally using javascript or jquery.

Apr 16

0

Vote

3

Answers

47

View

const myObject = new Object(); myObject["firstname"] = "Gareth"; myObject["lastname"] = "Simpson"; myObject["age"] = 21;

Jan 29

0

Vote

3

Answers

28

View

I'd like to store a JavaScript object in HTML5 localStorage, but my object is apparently being converted to a string.I can store and retrieve primitive JavaScript types and arrays using localStorage,

Jan 29

0

Vote

4

Answers

30

View

How do I append an object (such as a string or number) to an array in JavaScript?

Jan 29

0

Vote

4

Answers

43

View

I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery?I can get all of them like this:$("form :radio")How do I know which one is selected?

Jan 29

0

Vote

4

Answers

19

View

I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to:var obj1 = { food: 'pizza', car: 'ford' } var obj2 = { animal: 'dog' } obj1.merge(obj2); //ob

Jan 29

0

Vote

4

Answers

35

View

Mod note: This question is about why XMLHttpRequest/fetch/etc. on the browser are subject to the Same Access Policy restrictions (you get errors mentioning CORB or CORS) while Postman is not. This que

Jan 28

0

Vote

5

Answers

29

View

In JavaScript, how can I format a date object to print as 10-Aug-2022?

Jan 28

0

Vote

4

Answers

113

View

How can I display JSON in an easy-to-read (for human readers) format? I'm looking primarily for indentation and whitespace, with perhaps even colors / font-styles / etc.

Jan 28

0

Vote

5

Answers

20

View

How can I check the existence of an element in jQuery?The current code that I have is this:if ($(selector).length > 0) { // Do something } Is there a more elegant way to approach this? Perhap

Jan 28

0

Vote

4

Answers

28

View

What I am looking for:A way to style one HALF of a character. (In this case, half the letter being transparent)What I have currently searched for and tried (With no luck):Methods for styling half of a

0

Vote

4

Answers

20

View

Is there a better way to engineer a sleep in JavaScript than the following pausecomp function?function pausecomp(millis) { var date = new Date(); var curDate = null; do { curDate = new

Jan 17

0

Vote

5

Answers

26

View

What's the best way of checking if an object property in JavaScript is undefined?

Jan 17

0

Vote

4

Answers

67

View

I have the following code in Ruby. I want to convert this code into JavaScript. What is the equivalent code in JS?text = <<"HERE" This Is A Multiline String HERE

Jan 17

0

Vote

4

Answers

25

View

Can I convert a javascript string representing a javascript boolean value (e.g., 'true', 'false') into an intrinsic type in JavaScript?I have a hidden form in HTML that is updated based upon a user's

Jan 17

0

Vote

4

Answers

17

View

How can I change the class of an HTML element in response to an onclick or any other events using html javascript?

Jan 17

0

Vote

3

Answers

54

View

When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I'll use jQuery in the examples, but this applies to plain-JS as well:1. eve

Jan 17

0

Vote

4

Answers

19

View

What is the difference between using Function.prototype.apply() and Function.prototype.call() to invoke a function?var func = function() { alert('hello!'); };func.apply(); vs func.call();Are there

Jan 17

0

Vote

3

Answers

20

View

I have a JavaScript object like the following:var p = { "p1": "value1", "p2": "value2", "p3": "value3" };Now I want to loop through all p elements (p1, p2, p3...) And get their keys an

Jan 16

0

Vote

3

Answers

23

View

All I want is to get the website URL. Not the URL as taken from a link. On the page loading, I need to be able to grab the full, current URL of the website and set it as a variable to do with as I ple

Jan 16

0

Vote

3

Answers

25

View

I have an object x. I'd like to copy it as object y, such that changes to y do not modify x. I realized that copying objects derived from built-in JavaScript objects will result in extra, unwanted pro

Jan 16

0

Vote

3

Answers

30

View

I saw this question, but I didn't see a JavaScript-specific example. Is there a simple string.Empty available in JavaScript, or is it just a case of checking for ""?

Jan 16

0

Vote

3

Answers

26

View

I'd like to round at most 2 decimal places, but only if necessary.Input:10 1.7777777 9.1Output:10 1.78 9.1How can I do this in JavaScript?

Jan 16

0

Vote

4

Answers

50

View

I have an array of JavaScript objects:var objs = [ { first_nom: 'Lazslo', last_nom: 'Jamf' }, { first_nom: 'Pig', last_nom: 'Bodine' }, { first_nom: 'Pirate', last_nom: 'Prent

Jan 13

0

Vote

4

Answers

30

View

I am looking for a JavaScript array insert method, in the style of:arr.insert(index, item)Preferably in jQuery, but any JavaScript implementation will do at this point.

Jan 13

0

Vote

4

Answers

22

View

I saw some code that seems to use an operator I don't recognize, in the form of two exclamation points, like so: !!. Can someone please tell me what this operator does?The context in which I saw this

Jan 13

0

Vote

4

Answers

23

View

After an AJAX request, sometimes my application may return an empty object, like:var a = {};How can I check whether that's the case?

Jan 13

0

Vote

4

Answers

18

View

What is the best way to copy text to the clipboard (multi-browser)?I have tried:function copyToClipboard(text) { if (window.clipboardData) { // Internet Explorer window.clipboardData.set

Jan 13

0

Vote

3

Answers

66

View

I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.This happens on page-ready a

0

Vote

3

Answers

50

View

I started using Google Apps Script yesterday and I'm struggling in running the code successfully when I attempt to get a range of cells instead of just one cell.This is the complete code, it will show