lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I have two RxJS subjects , say a and b that I need to combine somehow.I want to combine them such that if a and b are updated synchronously , the values are delivered together : However , if just one value is updated , an update will still be pushed at the same time an update with two new values would be pushed : Is th... | someComboOfAandB.subscribe ( { aVal , bVal } = > console.log ( `` value : '' , aVal , bVal ) ) ; a.next ( 1 ) ; // some codeb.next ( 2 ) // at end of synchronous code / frame : // value : 1 2 a.next ( 5 ) // at end of synchronous code / frame : // value : 5 2 | Combine two RxJS streams ( based on synchrony ) |
JS | Obviously this was my typo , { x , y } should have been { x : x , y : y } . But it does what I want , in Chrome , field x gets the value of a local variable x.But why does it work ? | var obj = { type : 'data ' , x , y , data : [ ] } | why obj= { x , y } works in Chrome ? |
JS | I was reading Learning jQuery 1.3 ( Jonathan Chaffer and Karl Swedberg ) and while sorting table , they used .get ( ) before calling .sort ( ) , and said we need to transform jQuery objects into array of DOM nodes . Even though jQuery objects act like arrays in many respects , they do n't have any of the native array m... | $ ( `` # sort '' ) .click ( function ( ) { var posts = $ ( `` # posts_div .post '' ) ; posts.sort ( function ( a , b ) { return ( $ ( a ) .text ( ) ) > ( $ ( b ) .text ( ) ) ; } ) ; $ .each ( posts , function ( index , post ) { $ ( `` # posts_div '' ) .append ( post ) ; } ) ; } ) ; | Javascript methods that can not be called from jquery objects ? |
JS | I am new using OpenLayers ( an open-source JavaScript library for displaying map data in web browsers as slippy maps ) . I am using it with Thymeleaf ( a Java XML/XHTML/HTML5 template engine that can work both in web and non-web environments ) .I am trying to reproduce this example , but getting the resources from the ... | < ! doctype html > < html lang= '' en '' xmlns : th= '' http : //www.thymeleaf.org '' > < head > < title > Title < /title > < script src= '' https : //cdn.jsdelivr.net/gh/openlayers/openlayers.github.io @ master/en/v6.3.1/build/ol.js '' > < /script > < link rel= '' stylesheet '' href= '' https : //cdn.jsdelivr.net/gh/o... | OpenLayers : get Map , View , TileLayer and OSM from server |
JS | My apps front end is built in angular js 1.4.14 and I am encountering the following error only in IE-11 : Object does n't support property or method 'parseInt'Here is my Html : And here is my js code : Now , what is going wrong here ? My code is compiled when the app is run so the above error occurs in lib.js file whic... | < div class= '' form-group '' > < label class= '' col-sm-2 control-label '' > Pickup time < span ng-show= '' pickupTimeIsRange ( ) '' > range < /span > : < /label > < div class= '' row col-md-10 '' > < div class= '' col-md-3 '' > < input placeholder= '' { { pickupTimeIsRange ( ) ? 'Start time ' : 'Time ' } } '' class= ... | IE-11 : Object does n't support property or method 'parseInt ' |
JS | I would to know something about a scope behavior.For example I have a variable and a function : This will display 1 and 2 . No problem . But if I do this : This will display 'undefined ' and ' 1 ' . Why does the variable come out as 'undefined ' ? | var test = 1 ; function scope ( ) { alert ( test ) ; test=2 ; } scope ( ) ; alert ( test ) ; var test = 1 ; function scope ( ) { alert ( test ) ; var test = 2 ; } scope ( ) ; alert ( test ) ; | JavaScript unexpected variable scope behavior |
JS | I get this every time I try and deploy my app to android and it breaks my metro server.I have tried updating my environment variables . | events.js:174 throw er ; // Unhandled 'error ' event ^Error : EPERM : operation not permitted , lstat ' C : \Users\user\Documents\DEV\react-native-dualscreen\dualscreeninfo\examples\android\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\androidx\lifecycle\viewmodel'Emitted 'error ' eve... | event.js:174 throw er// unhandled 'error ' event operation not permitted |
JS | I have a tab navigation link ( tab1 , tab2 , tab3 ) and the bottom of the page there is a page link navigation for each tabs.for tabs highlightfor page highlightalthough a page link and a tab link were highlighted correctly for each functions how can i highlight current tab ( after clicking page link ) and current page... | $ ( document ) .ready ( function ( ) { var str=location.href.toLowerCase ( ) ; $ ( `` .tabs li a '' ) .each ( function ( ) { if ( str.indexOf ( this.href.toLowerCase ( ) ) > -1 ) { $ ( `` li.highlight '' ) .removeClass ( `` highlight '' ) ; $ ( this ) .parent ( ) .addClass ( `` highlight '' ) ; } } ) ; } ) $ ( document... | highlight both page and matching tab in jquery |
JS | I ca n't figure out how this recursive call works . Using the not operator in the recursive call somehow makes this function determine if the argument given is odd or even . When the ' ! ' is left out fn ( 2 ) and fn ( 5 ) both return true.This example is taken out of JavaScript Allonge free e-book , which , so far has... | var fn = function even ( n ) { if ( n === 0 ) { return true ; } else return ! even ( n - 1 ) ; } fn ( 2 ) ; //= > truefn ( 5 ) ; //= > false | Negation operator ( ! ) used on a recursive call ? |
JS | Normally , in Javascript , when I want to pass an anonymous/inline function as an argument to another function , I do one of the following.However , I 've recently inherited a codebase that uses named function as inline arguments , like thisI 've never seen this syntax before . The function still seems to be anonymous ... | someFunctionCall ( function ( ) { // ... } ) ; someFunctionCall ( ( ) = > { // ... } ) ; someFunctionCall ( function foo ( ) { // ... } ) ; | Differences Between Named and Unnamed Anonymous Javascript Functions |
JS | I have an array iterator function : and some codeWhy is typeof this within the inline function object instead of string ? jsfiddle here | function applyCall ( arr , fn ) { fn.call ( arr [ 0 ] , 0 , arr [ 0 ] ) ; } var arr1 = [ 'blah ' ] ; applyCall ( arr1 , function ( i , val ) { alert ( typeof this ) ; // object WHY ? ? alert ( typeof val ) ; // string alert ( typeof ( this === val ) ) // alerts false , expecting true } ) ; | JavaScript : unexpected typeof result |
JS | I am trying to call multiple sheets from the excel file , by implementing single promise statement but it always outputs the data of first sheet.Thank you.Need to call both sheets data using single promise statement . | alasql.promise ( 'select * from xls ( `` raw/food.xls '' , [ { sheetid : '' Data '' } , { sheetid : '' Guideline '' } ] ) ' ) .then ( function ( data ) { console.log ( data ) ; } ) .catch ( function ( err ) { console.log ( 'Error : ' , err ) ; } ) ; | Alasql -Multiple sheetids within single promise statement |
JS | I was creating a solution to an ICPC problem using JavaScript and Node.js when I ran into an interesting issue : under certain circumstances my program would run twice as slow on the same data set.I stripped it down until I got to this minimal example that demonstrates the behavior : This is the output of running node ... | function solve ( arr ) { const total = arr.reduce ( ( a , c ) = > a + c , 0 ) ; const count = arr.length ; for ( let i = 0 ; i < total ; i++ ) { for ( let j = 0 ; j < count ; j++ ) { // calculate some stuff } } } for ( let i = 0 ; i < 10 ; i++ ) { // generate some sample data ( array of 5000 random numbers 1-10 ) const... | Why does this JavaScript code run slower after Node.js optimization |
JS | Why would you use this syntax ? instead ofEdit : I just had a thought that if in the case of the & & || syntax both sides of the || evaluated to false , as you might expect if myObject was undefined or null , if false would be returned . But it is n't , the objects value undefined or null is returned . Edit2 : This doe... | var myVar = myArray.length & & myArray || myObject ; var myVar = myArray.length ? myArray : myObject ; true || true //truetrue || false //truefalse || true //truefalse || false //false ! ! ( myArray.length ? myArray : myObject ) ; | ' & & ' and '|| ' vs ' ? : ' |
JS | I 'm writing some code comments using JSDoc style , and want to know what *= implies in @ returns { function ( *= ) : * } , which is generated by WebStorm.I have tried to search the JSDoc wiki and usejsdoc.org but with no result.Below is my code : I want to know what *= implies in @ returns { function ( *= ) : * } . | /** * Get record data listener generator . * @ param { Function } createProps * @ returns { function ( *= ) : * } // ** generated by webstorm ** */export function getRecordCustomDataListener ( createProps ) { return ( callback ) = > onRecordCustomData ( { createRecordData : createProps } ) ( callback ) ; // ` onRecordC... | What does ` function ( *= ) ` imply in a JSDoc-style code comment ? |
JS | I am validating an email address using the following regexNow the problem is that it is showing unexpected behaviorIf I enter email address likeThis is accepted by the above regex as validate format of email addressBut when I use formatThe regex do n't validate it as email formatsimilarlyis a not a validate format whil... | var regex=/^ ( [ A-Za-z0-9_\-\. ] ) +\ @ ( [ A-Za-z0-9_\-\. ] ) +\ . ( [ A-Za-z ] { 2,4 } ) $ / ; pakistan @ gmail.com igz.dwd.08 @ gmail.com abcdef @ gmail.com awaisobaidzaid @ gmail.com igz.dwd.08 @ gmail.com | Unexpected behaviour of regex validating email |
JS | here what i am doing is i am creating a `` Drag n Drop feature '' using ng2 file upload and here my issue is when ever im trying to drop more than one file the select all function will be enabled and it will select all check boxes by default but that is not happening in my scenario after file drophttps : //stackblitz.c... | < div class= '' container '' > < div class= '' well well-lg metadata-well text-center add-file `` > < h4 style= '' float : left `` > < span *ngIf= '' uploader ? .queue ? .length > 1 '' > & nbsp ; < input type= '' checkbox '' id= '' selectAll '' [ ( ngModel ) ] = '' selectAll '' ( change ) = '' selectAllFiles ( $ event ... | having issue in select all check boxes at the time on file drop using angular |
JS | When I click on this box Firefox selects the text . If the div is not empty the text is not selected . Why is that ? Demo | < div style= '' float : left ; width:100px ; height:100px ; border:1px solid black ; '' onclick= '' this.innerHTML = 'TEST ' ; '' > < /div > | Why does firefox select the text when I change innerHTML |
JS | I wrote a simple Sudoku solver using backtracking in JS . In effort to be `` purely functional '' all my 9x9 puzzle arrays are immutable thus a new array is created whenever a new number is inserted . Version 1 using new SudokuPuzzleIn the first version I use the new Puzzle ( puzzle ) approach to clone the object : The... | function SudokuPuzzle ( obj ) { if ( obj instanceof SudokuPuzzle ) { this.grid = obj.grid.slice ( 0 ) ; // copy array } // ... } SudokuPuzzle.prototype.update = function ( row , col , num ) { var puzzle = new SudokuPuzzle ( this ) ; // clone puzzle puzzle.grid [ row*9 + col ] = num ; // mutate clone return puzzle ; // ... | Why is Node 's Object.create ( foo ) much slower than new Foo ( ) ? |
JS | I have a table that looks like : Is there an easy way to get an array of the < col / > tags ? I do n't want to use getElementById because I do n't know the ids of the col tags , although I will know the Id of the table . I do n't want to use getElementsByTagName because there will be several tables in the document with... | < table id= '' myTable '' > < col id= '' name '' / > < col id= '' birthYear '' / > < col id= '' phone '' / > < td > < tr > Joe < /tr > < tr > 1972 < /tr > < tr > 202-555-1234 < /tr > < /td > < /table > | Is there a way to access an array of col tags for a table in javascript ? |
JS | I am making a sortable and resizable image album . In there , I am trying to add a feature to create the image as a link.Image is clickedThen wrap that image with a div which displays an edit button on top of that image.And when the edit button is clicked a dialog box will appear to enter the url and name for that imag... | $ ( ' # sortable li img ' ) .on ( `` click '' , function ( ) { $ image = $ ( this ) ; image_resize ( $ image ) ; edit_image ( $ image ) ; } ) ; function edit_image ( image ) { image.wrap ( ' < div id= '' edit-image '' > < /div > ' ) ; $ ( ' # edit-image ' ) .prepend ( ' < a href= '' # '' > EDIT < /a > ' ) ; $ ( `` # ed... | How to check if the same image or another image or something other than the image is clicked |
JS | Which is faster : or | if ( var == 'value ' ) if ( /value/.test ( var ) ) | Which is faster : if ( var == 'value ' ) OR if ( /value/.test ( var ) ) |
JS | I have converted the uploaded image into progressive in backend using Node GM and stored in the file . After that , I want to show that converted progressive images in front-end . My problem is when I rendered that image its getting rendered line by line . But compared to normal image these progressive images are loadi... | < html > < head > < /head > < body > < h1 > Hello < /h1 > < img style= '' width:50 % '' src= '' https : //www.dropbox.com/s/p57ik1kl04k1iax/progressive3.jpg ? raw=1 '' / > < img style= '' width:30 % '' src= '' https : //www.dropbox.com/s/3nnc03tfwxrpu5q/Porsche-GT2-4K-UHD-Wallpaper.jpg ? raw=1 '' / > < /body > < /html ... | To render the Progressive Image in Progressive manner |
JS | So I 've been working on this script all day and all the examples I 've seen just do n't seem to do what I want . Here 's my example CodePen . Try to hover over `` MENUS '' and over `` SETTINGS '' . I 'll try to explain the problem with words : The Script : The above code gives the blue line ( class active-2 ) to the a... | var activeItem = $ ( `` # menu .active '' ) ; var items = $ ( `` # menu .main : not ( .active ) '' ) ; activeItem.addClass ( `` active-2 '' ) ; items.hover ( function ( ) { `` use strict '' ; activeItem.toggleClass ( `` active-2 '' ) ; } ) ; $ ( document ) .mousemove ( function ( event ) { `` use strict '' ; if ( $ ( `... | addClass on hover for multiple items |
JS | I 'm attempting to build a simple Ember application that collects information from a form . I 'm using this tutorial as a guide . In the tutorial it has the following code to grab information from a form : here is a bit of the relevant form code : In my solution I could not get this to work . this.get ( 'whatever ' ) a... | export default Ember.Component.extend ( { ... actions : { saveRental1 ( ) { var params = { owner : this.get ( 'owner ' ) , city : this.get ( 'city ' ) , type : this.get ( 'type ' ) , image : this.get ( 'image ' ) , bedrooms : this.get ( 'bedrooms ' ) , } ; ... this.sendAction ( 'saveRental2 ' , params ) ; } } } ) ; < d... | In Ember , what is the difference between this and this.controller |
JS | When an array is created , I need a function to be called on that array automatically . I figured this would be possible using the Array 's prototype / constructor somehow , but I 'm at a loss as to how to solve this problem.So I have an Array , which I initialise : Now let 's say I have a function like so : So in this... | var arr = [ 1 , 2 , 3 ] ; Array.prototype.objectArray = function ( ) { var result = this.every ( function ( elem ) { return typeof elem == `` object '' ; } ) ; this.isObjectArray = result ; } | Is it possible to carry out a function every time an Array is created ? |
JS | Code 1 : Code 2 : Edit : So , Guys , you mean the Second one is better ? or more `` formal '' ? | var Something = { name : `` Name '' , sayHi : function ( ) { alert ( Something.name ) ; } } function Something ( ) { this.name = `` Name '' ; } Something.prototype.sayHi = function ( ) { alert ( Something.name ) ; } | What is the difference between these two code samples ? |
JS | i have this code : now , when i made : For example , if i choose the value 1/8 it is sent as 1 , or 9/1 as 16.What i want is send the fraction value , that is showed in the input box , but as i said , not sent to the insert.phpAny idea ? thanks | var sizes = [ `` 1/9 '' , '' 1/8 '' , '' 1/7 '' , '' 1/6 '' , '' 1/5 '' , '' 1/4 '' , '' 1/3 '' , '' 1/2 '' , '' 1/1 '' , '' 2/1 '' , '' 3/1 '' , '' 4/1 '' , '' 5/1 '' , '' 6/1 '' , '' 7/1 '' , '' 8/1 '' , '' 9/1 '' ] ; var slider = new dijit.form.HorizontalSlider ( { value:8 , name : '' value '' + [ i ] , slideDuratio... | strange behaviour - serialize |
JS | I am getting spam due to gmail allowing the use of . in their emails , so someone like this spammer.can get through by removing and/or adding another period in his naming structure . This happens to be on a Joomla install , so I am specifically looking to create a component so I can add to multiple sites , or if there ... | q.i.n.ghu.im.i.n.g.o.u.r @ gmail.com | Looking for a PHP regex or function to filter variations using . of an email for security |
JS | So i have been playing with promises for the last few days , and just trying to convert some project , to use promises , but more than a few times i have encuntered this issue.While reading articles and tutorials everything looks smooth and clean : But in reality , its not like that . Programs have a lot of `` if condi... | getDataFromDB ( ) .then ( makeCalculatons ) .then ( getDataFromDB ) .then ( serveToClient ) getDataFromCache ( data ) .then ( function ( result ) { if ( result ) { return result ; } else { return getDataFromDB ( ) ; } } ) .then ( function ( result ) { if ( result ) { serveToClient ( ) //this does not return a promise ,... | Correct pattern for multiway flows with Promises |
JS | I have the following code where I edit the field of a row in a table , but I want it to be more Dynamic , that is , when editing a field it jumps to the next field where I will edit . I have a success function where I should jump to the next field to edit what the Item would be , but I do not know why it does not work.... | $ ( ' # table ' ) .editable ( { container : 'body ' , selector : 'td.task ' , title : 'task ' , type : `` POST '' , showbuttons : false , type : 'text ' , validate : function ( value ) { if ( $ .trim ( value ) == `` ) { return 'Empty ! ' ; } } , success : function ( response ) { //WITH THIS CODE I COULD JUMP BUT THE LI... | Dynamic table - auto-show |
JS | So i have the below function to get my posts , but i want user to go directly on a page where posts have date `` today '' thats not a event publish date but an date for when event is happening , like if i have events that have man_date field 2015-4-12 and today is 2015-4-12 i will see directly the page where that event... | function get_table ( ) { global $ wpdb ; $ c_cid = $ _REQUEST [ 'cat ' ] ; if ( isset ( $ _REQUEST [ `` page '' ] ) ) { $ page_number = filter_var ( $ _REQUEST [ `` page '' ] , FILTER_SANITIZE_NUMBER_INT , FILTER_FLAG_STRIP_HIGH ) ; //filter number if ( ! is_numeric ( $ page_number ) ) { die ( 'Invalid page number ! ' ... | Take user directly to the page where event date matches the current date ( pagination ) |
JS | I am working within the constraints of a content management system that sometimes forces me to do some odd things because I do n't have full control of the HTML code.In this instance , I have a situation where I want one DIV to not be nested inside another DIV . Because of the CMS settings , I ca n't just re-order the ... | < div class= '' blog '' > < div class= '' free-me '' > Hello world < /div > < /div > < div class= '' blog '' > < /div > < div class= '' free-me '' > Hello world < /div > < div class= '' blog '' > < /div > .free-me : :before { content : ' < /div > ' ; } | Can I use JavaScript or CSS to close a previous div ? |
JS | If I compute the current local time in Montevideo with the following code : I get : 11/29/2015 , 9:46:10 AMIf I check this time on the web , for instance with : http : //www.zeitverschiebung.net/en/timezone/america -- montevideoI get : 11/29/2015 , 8:46:10 AMWhy is there 1h difference ? | var dt = new Date ( ) .toLocaleString ( `` en-US '' , { timeZone : `` America/Montevideo '' } ) console.log ( dt ) ; | Timezone America/Montevideo |
JS | I have typical organization hierarchy . For example.A is the top most node . But I receive this data as a flat array with an attribute pointing to the parent.But I want to convert this in to single nested object or a tree . A root node has children attribute with the children embedded and each child has its own childre... | D , E is reporting to B. B , C is reporting to A . [ { name : `` A '' , parent : null } , { name : `` B '' , parent : `` A '' } , { name : `` C '' , parent : `` A '' } , { name : `` D '' , parent : `` B '' } , { name : `` E '' , parent : `` B '' } ] { name : `` A '' , children : [ { name : `` C '' children : [ { name :... | Converting an array into a nested object in javascript |
JS | Consider this simple .js code : // UsageI 'm pretty sure c # support first class function , note that I do n't want to use classes to remake the code above . What is the equivalent closure in c # ? I have made this : | const createCounter = ( ) = > { let value = 0 ; return { increment : ( ) = > { value += 1 } , decrement : ( ) = > { value -= 1 } , logValue : ( ) = > { console.log ( value ) ; } } } const { increment , decrement , logValue } = createCounter ( ) ; public Func < WhatType ? > CreateCounter = ( ) = > { var value = 0 ; retu... | What is the equivalent javascript closure in c # ? |
JS | I do n't know if this is the right place to ask this question but I 'm just going to do it.I 've been trying to figure out how I want to give out my web application.This is my situation : I 've created a web application . People who want to use this application are free to do so . BUT they need to be signed up on our w... | < script type='text/javascript ' data-cfasync='false ' > window.exampleApi = { l : [ ] , t : [ ] , on : function ( ) { this.l.push ( arguments ) ; } } ; ( function ( ) { var done = false ; var script = document.createElement ( 'script ' ) ; script.async = true ; script.type = 'text/javascript ' ; script.src = 'https : ... | Give out widget ( web application ) with activation code |
JS | I 'm reading the KnockoutJS source code . I ran into the following line which I 'm not sure I understand ... Generally , the structure seems to be along the lines of : I do n't understand this construct , why is new needed ? What does it do ? What is it useful for ? ( I thought that if a function is called with new bef... | ko.utils = new ( function ( ) { ko.utils = new ( function ( ) { // some variables declared with var return { export : value , export : value } ; } ) ( ) ; | `` new '' Before Anonymous Function Invocation Returning Object |
JS | Assume that I have Foo.class in Java : And that I have Foo `` class '' in JavaScript : Also , assume that I have Java controller that returns instance of Foo.class as a response to a REST request . In my JavaScript ( AngularJS ) code the request is sent as : And it works . But is there a way to avoid passing every prop... | public class Foo { public int id ; public String data ; } function Foo ( id , data ) { this.id = id ; this.data = data ; } $ http.get ( url + 'bar/get-foo/ ' ) .success ( function ( response ) { var foo = new Foo ( response.id , response.data ) ; logger.info ( `` SUCCESS : /get-foo '' ) ; } ) .error ( function ( error_... | Is there a way to `` expect '' instance of certain Java class in JavaScript code ? |
JS | In most javascript apps I usually declare an array like sobut I 've seen a ton of example code on MDN that take this approach insteadWith V8/other modern JS engines , do you see a real benefit one way or the other ? | var x = [ ] ; var x = new Array ( 10 ) ; | What benefit do you get in javascript declaring an array with a specific length ? |
JS | In the past when creating `` classes '' in JavaScript , I have done it like this : However , I just saw someone do it like this instead : Can you do it both ways , or is the way I 've done it wrong ? In that case , why ? And what exactly is the difference between the two in terms of what we end up with ? In both cases ... | function Dog ( name ) { this.name=name ; this.sound = function ( ) { return `` Wuf '' ; } ; } var Dog = ( function ( ) { function Dog ( name ) { this.name = name ; } Dog.prototype.sound = function ( ) { return `` Wuf '' ; } ; return Dog ; } ) ( ) ; var fido = new Dog ( `` Fido '' ) ; fido.sound ( ) ; | Confusion about how to create classes in JavaScript |
JS | I have a progressively enhanced < select > element in HTML.It uses the following form , With the current implementation , the click event handler is attached to every li element.Will this create a problem when you have , say , about 1000-2000 elements , will it be slower as compared to attaching a single event handler ... | < ul > < li > < /li > < li > < /li > ... < /ul > < div > < select > //1000-2000 elements < option > < /option > < /select > < ul > //Mapping the values of the 1000-2000 option tags < li > < /li > < /ul > < /div > | Event handlers in JavaScript for a progressively enhanced ` select ` element |
JS | Here is the snippet of a Svelte component : Could somebody explain what is the purpose of $ : before the area variable ? Thanks in advance . | < script > let radius = 10 ; $ : area = Math.PI * radius ** 2 ; // ... < /script > | Svelte : What does $ : mean ? |
JS | I am following the solutions from here : How can I return a JavaScript string from a WebAssembly functionand here : How to return a string ( or similar ) from Rust in WebAssembly ? However , when reading from memory I am not getting the desired results.AssemblyScript file , helloWorldModule.ts : index.html : This retur... | export function getMessageLocation ( ) : string { return `` Hello World '' ; } < script > fetch ( `` helloWorldModule.wasm '' ) .then ( response = > response.arrayBuffer ( ) ) .then ( bytes = > WebAssembly.instantiate ( bytes , { imports : { } } ) ) .then ( results = > { var linearMemory = results.instance.exports.memo... | Working with memory to fetch string yields incorrect result |
JS | There are a couple rules that are arguably good to follow when writing code : Code is easier to read and reason about when there 's no reassignment ; many linters recommend preferring const whenever possible.Code is also easier to read and reason about when objects do not get mutated . If you define an object in one pa... | const module = ( ( ) = > { // Reassignment , but no mutation : let savedData ; return { getData : ( ) = > savedData , setData : ( newData ) = > savedData = newData } ; } ) ( ) ; module.setData ( 'foo ' ) ; console.log ( module.getData ( ) ) ; const module = ( ( ) = > { // Mutation , but no reassignment : const savedDat... | How to implement settable and retrievable state without mutation nor reassignment ? |
JS | How can I select with plan javascript or jQuery every element which has an attribute that starts with `` data- '' ? I 've triedbut it does n't work . | $ ( `` [ data-* '' ] ) | Select elements which start with `` data- '' |
JS | Everything workes until the last row . It doesn´t make an addition , it puts together the variables into one string . If myX is 10 and difference is 20 it will be 1020 when I want it to be 30.How do I solve this ? | var x = e.pageX ; var myX = $ ( this ) .html ( ) ; var difference = myX - x ; var ex = myX + difference ; | It puts strings together instead of adding them Javascript |
JS | From the docs , it says `` React may batch multiple setState ( ) calls into a single update for performance '' so it recommends using a function instead of an object for setState 's argument . How does this solve the problem ? | // Wrongthis.setState ( { counter : this.state.counter + this.props.increment , } ) ; // Correctthis.setState ( ( prevState , props ) = > ( { counter : prevState.counter + props.increment } ) ) ; | Why does using function inside React 's # setState solve async issues ? |
JS | I read that this event listener made sure , for regular scripts , that the JS was n't going to reference nodes that had n't been loaded yet . The content executes after DOMContentLoaded has been fired ) .I 've also read that a module is executed before DOMContentLoaded is fired ( due to the defer attribute it has built... | document.addEventListener ( 'DOMContentLoaded ' , ( ) = > { } ) ; | Do modules prevent the need to use the DOMContentLoaded listener ? |
JS | I have the following object : I want to get the length of thisbut that returns undefined . Obviously I 'm looking to get 3 as the answer . | var l= { `` a '' :1 , '' b '' :2 , '' c '' :5 } ; alert ( l.length ) ; | Getting length of an object |
JS | First I 've created a basic demonstration of what I have at the moment here . Second this is the javascript I 'm using . What I 'm hoping to achieve is to have each box hover one after the each other with a delay time of 250 . I 've tried adding a delay to the animation function ( as you can see above ) and also a setT... | var boxes = [ `` # one '' , '' # two '' , '' # three '' , '' # four '' ] ; boxhover = function ( a ) { $ ( `` # hover '' ) .hover ( function ( ) { $ ( a ) .stop ( true ) .delay ( 250 ) .animate ( { opacity:1 } ) ; } , function ( ) { $ ( a ) .stop ( true ) .delay ( 250 ) .animate ( { opacity:0 } ) ; } ) } for ( var i=0 ... | How to increase the delay on animation on every pass of a for loop |
JS | I am working in a angular4 project where I had used ngx-slimscroll which has the tag with attribute as given below < perfect-scrollbar [ config ] = '' configForScroll '' > < /perfect-scrollbar > .Now , here my requirement is to create < perfect-scrollbar > element dynamically using document.createElement ( ) function w... | var patt = document.createAttribute ( `` [ config ] '' ) ; patt.value = `` configForScroll '' ; | is it possible to set the attribute as [ config ] with value as configForScroll using setAttribute in javascript ? |
JS | I often do stuff like this : But I actually want to permit 0 , and 0 || 24 === 24 , instead of 0.I 'm wondering what the best pattern is to take user input from command line , or input from wherever , and do the same logic , only treat zero as truthy . I think the best pattern I 've found is to do exactly that : Firstl... | delay = delay || 24 ; // default delay of 24 hours delay = ( delay === 0 ? delay : ( delay || 24 ) ) ; delay = typeof delay === 'number ' ? delay : 24 ; // but typeof NaN === 'number ' , sodelay = ( ! isNaN ( delay ) & & typeof delay === 'number ' ) ? delay : 24 ; str = typeof str === 'string ' ? str : 'default ' ; del... | Pattern for treating zero as truthy |
JS | Disclaimer : my question is not focused on the exercise , it 's just an example ( although if you have any interesting tips on the example itself , feel free to share ! ) .Say I 'm working with parsing some strings with Regex in JavaScript , and my main focus is performance ( speed ) .I have a piece of regex which chec... | if ( /^\ [ [ 0-9 ] + ] $ /.test ( str ) ) { val = Number ( str.match ( /^\ [ ( [ 0-9 ] + ) $ / ) [ 1 ] ) ; } | Is there a performance penalty using capture groups in RegExp # test ? |
JS | I am implementing Highcharts in my application . It needs data in specific format . The data in my table is as followsThe javascript needs data in below formatWhen I var_dump my x_axis array and y_axis array , I get below resultWhich php functions should I use to format my array elements and pass to that JavaScript in ... | data : [ [ < ? echo PHP_some_function ( `` ' `` , x_axis ) ? > , < ? echo ( y_axis ) ? > ] //quotes for x , no quotes for y value ] //Moreover it should run for all the values in x_axis and y_axis | DB Array to expected javascript format |
JS | Running the following code : Outputs `` 3 '' three times . It 's outputting the final value of i as opposed to the value of i when the inner function is created.If I want the output to be 1 , 2 , and 3 , how would I write this code ? How can I get it to use the value of i at the time the function is defined as opposed ... | for ( var i=0 ; i < 3 ; i++ ) { setTimeout ( function ( ) { console.log ( i ) ; } , 500 ) ; } | JavaScript scoping with closure : help me understand |
JS | Taking the learning to program plunge . I am not concerned about the best practice for where to insert javascript code into an HTML document . Rather please help me understand why the following code did not log to console in Edge browser . | < head > < title > Layout Work < /title > < meta lang= '' en '' charset= '' utf-8 '' > < link rel= '' stylesheet '' type= '' text/css '' href= '' css/normalize.css '' > < link rel= '' stylesheet '' type= '' text/css '' href= '' css/style.css '' > < script > var bottles = 99 ; var beerSongPartOne = `` bottles of beer on... | < script > < /script > in header does not log to console in edge browser |
JS | Let us consider the following JavaScript snippetI was astonished to see the output as [ Object { name= '' you '' } , Object { name= '' you '' } ] As we are pushing the references , both must refer to same object . But at least after the first push output must be like Object { name= '' me '' } Why is this happening ? ? ... | var arr = [ ] ; function pushMe ( ) { var temp = { `` name '' : `` me '' } ; arr.push ( temp ) console.log ( arr ) temp [ `` name '' ] = `` you '' ; arr.push ( temp ) console.log ( arr ) } | weird behaviour of javascript with arrays |
JS | I 'm trying to create a JavaScript card game and want to pick 5 cards without repetition : How can I make sure that there is no repetition if I pick 5 cards ? | var colors = [ `` hearts '' , `` spades '' , `` diamonds '' , `` clubs '' ] ; var values = [ `` 2 '' , `` 3 '' , `` 4 '' , `` 5 '' , `` 6 '' , `` 7 '' , `` 8 '' , `` 9 '' , `` 10 '' , `` J '' , `` Q '' , `` K '' ] ; color = colors [ parseInt ( Math.random ( ) *colors.length,10 ) ] value = values [ parseInt ( Math.rando... | How to mix values in a JavaScript array without repetition ? |
JS | The first couple paragraphs describe what I 'm trying to achieve , the actual question is at the end . ThanksPreviously , I 've simply been using new keyword to create objects , and prototypes to assign methods and handle inheritance . Recently , however , ( partially inspired by CoffeeScript-generated JS ) I decided t... | var Test = function ( a ) { function Test ( a ) { this.a = a ; } var numCalls = 0 ; Test.prototype.output = function ( ) { alert ( ' I was initialized with ' + this.a ) ; numCalls++ ; } ; Test.prototype.called = function ( ) { alert ( 'You called the output ' + numCalls + ' times ' ) ; } ; return new Test ( a ) ; } ; v... | object-creating function |
JS | I am trying to write a web worker that performs an interruptible computation . The only way to do that ( other than Worker.terminate ( ) ) that I know is to periodically yield to the message loop so it can check if there are any new messages . For example this web worker calculates the sum of the integers from 0 to dat... | let currentTask = { cancelled : false , } onmessage = event = > { // Cancel the current task if there is one . currentTask.cancelled = true ; // Make a new task ( this takes advantage of objects being references in Javascript ) . currentTask = { cancelled : false , } ; performComputation ( currentTask , event.data ) ; ... | Is there a faster way to yield to Javascript event loop than setTimeout ( 0 ) ? |
JS | I have this javascript objects : How can I merge or add newArr to the related CountryArray . Expected result : | var countryArray = [ { `` country '' : 'Indonesia ' , `` state '' : [ 'DKI ' , 'Bali ' ] , } , { `` country '' : 'Malaysia ' , `` state '' : [ 'Penang ' , 'Johor ' ] , } ] ; var newArr = [ { `` country '' : 'Malaysia ' , `` state '' : [ 'Kelantan ' ] } ] var countryArray = [ { `` country '' : 'Indonesia ' , `` state ''... | Merge new array objects to existing object js |
JS | I am using vue.js in this case but I guess it would apply in plain JS too . The problem is that when I am in a function that is in another function I am having to call variables by their full path like - Object.variable instead of this.variable . Is there a way to use this.timer , this.pages instead of TVComponent.page... | const TVComponent = new Vue ( { el : '.tvContent ' , data : { current_page : 0 , timer : 0 , pages : [ { page : '/ ' , interval : 10 } , { page : 'tv/calls ' , interval : 10 } , { page : 'tv/general ' , interval : 10 } ] } , methods : { tvTimer ( ) { setInterval ( function ( ) { TVComponent.timer++ ; if ( TVComponent.t... | Can not use 'this ' keyword in an object because it is inside another function |
JS | So I 'm experimenting with ES6 , installed the grigio : babel package , and am starting to go through my es5 code and update it to some of the new ES6 syntax when I ran into a problem.Originally my template helpers looked something like this : which is used in a Blaze each loop as suchAs you 'd expect , all of my event... | Template.exampleTemplateName.helpers ( { exampleHelper : function ( ) { //returns an array from Mongo Collection } } ) ; { { # each exampleHelper } } { { /each } } Template.exampleTemplateName.helpers ( { exampleHelper ( ) { //returns an array from Mongo Collection } } ) ; Template.exampleTemplateName.helpers ( { examp... | Meteor : Why am I losing my data context by switching function ( ) { } to ( ) = > { } ? |
JS | I 'm using dropdowns from PrimeReact . I have to implement them so that the values from the first upper main dropdown change the values of all the lower ones , which I already did , but then I need than each dynamically dropdown from the lower block have to change change only its unique value : I can not understand... | class LeagueCard extends Component { state = { selectedItemDefaultDropDown : this.props.cardContent.insuranceVariants [ 0 ] , selectedItemPersonallyDropDown : null } ; createOptions = ( arr ) = > { return arr.map ( item = > ( { label : item , value : item } ) ) } ; render ( ) { const { cardIndex , cardContent : { insur... | Multiple dropdowns implementation with one main dropdown |
JS | What is the difference in JavaScript between calling something like this : and ( result is the same in the loadData function ) : I have used JavaScript for simple tasks ( input validation , simple ajax calls ) until now but now I need some deeper undestanding ... | var reader = new FileReader ( ) ; reader.onload = ( function ( theFile ) { return function ( e ) { loadData ( e.target.result ) ; } ; } ) ( file ) ; reader.readAsText ( file ) ; var reader = new FileReader ( ) ; reader.onload = function ( e ) { loadData ( e.target.result ) ; } ; reader.readAsText ( file ) ; | Assigning anonymous function that returns anonymous function |
JS | There 's a similar discussion here : CSS data attribute new line character & pseudo-element content valueProblem is , this did n't work if the attr is set via JavascriptI understand that \A does n't work in attr , but now & # xa ; does n't work on attr via Javascript , is there any way to get this working ? | const ele = document.getElementById ( 'my-ele ' ) ele.classList.add ( 'loading ' ) ; ele.setAttribute ( 'loading-text ' , 'Your file is being generated ... & # xa ; This may take some minutes ' ) ; .loading : :after { content : attr ( loading-text ) ; } < div id= '' my-ele '' > < /div > | CSS pseudo-element content value with line-break via attr inserted by Javascript |
JS | I 've seen the Google Closure compiler do a lot of rewriting in if-clauses . For example : turns toAre comparisons faster in JavaScript , if the primitive is the first argument , or what is the reason for this ? | if ( a === 3 ) { … } if ( 3 === a ) { … } | Why does Google Closure swap arguments ? |
JS | I do not understand why these two JS expressions are not equivalentIn order to get better at JS , I am experimenting with some javascript expressions . Here is my latest discovery : Could anyone help me understand that ? | { a : y = 1 } = { b : 2 } // { b : 2 } { a : 1 } = { b : 2 } // Uncaught SyntaxError : Unexpected token = | Why is { a : y = 1 } = { b : 2 } valid and { a : 1 } = { b : 2 } a SyntaxError ? |
JS | I just learned that I can overwrite a method in a Javascript class , as shown below , but what about the actual constructor ? If possible , how do I do it without instantiating the class ? | var UserModel = ( function ( ) { var User ; User = function ( ) { } ; // < - I want to overwrite this whilst keeping below methods User.prototype.isValid = function ( ) { } ; return User ; } ) ( ) ; | Can I overwrite a constructor in javascript ? |
JS | What is a prototype for a JavaScript class ? In other words , what is the difference betweenand when defining the Example class ? Edit : For those interested , I found a great explanation ( in addition to the answer below ) here for the difference between class methods and constructor methods : http : //idhana.com/2009... | Example.prototype.method { } Example.method { } | What are prototypes in JavaScript ? |
JS | Take the following codeWhat year is year 0000 ? After all , year 0 is n't actually a thing , since we went from 1BC to 1AD . Is year 0 actually 1BC and year -1 actually 2BC ? | var d = new Date ( ) ; d.setFullYear ( 0 ) ; alert ( d ) ; | What is year 0 in Javascript ? |
JS | I have a long string containing CSV data from a file . I want to store it in a JavaScript Array of Arrays . But one column has arbitrary text in it . That text could contain double-quotes and commas.Splitting the CSV string into separate row strings is no problem : var theRows = theCsv.split ( /\r ? \n/ ) ; But then ho... | var theArray = new Array ( ) ; for ( var i=0 , i < theRows.length ; i++ ) { theArray [ i ] = theRows [ i ] .split ( ' , ' ) ; } 512 , '' '' '' Fake News '' '' and the `` '' Best Way '' '' to deal with A , B , and C '' , 1/18/2019 , media `` Fake News '' and the `` Best Way '' to deal with A , B , and C | How to split a string containing CSV data with arbitrary text into a JavaScript Array of Arrays ? |
JS | I have this code : I 'm trying to color all letters every 3 seconds using the setTime ( ) function . Note : I 'm trying to color each letter of a word , in other words , each letter will have a colorLike : https : //i.imgur.com/Tw2Q58U.pngI tried with this code , but it changes the color of the entire div ( The div sta... | < div id= '' list '' rows= '' 10 '' > < /div > < script > $ ( function ( ) { setTime ( ) ; function setTime ( ) { $ .ajax ( { url : `` ../abc.php '' , dataType : `` text '' , success : function ( result ) { $ ( `` # list '' ) .html ( result ) ; } } ) ; var date = new Date ( ) .getTime ( ) ; setTimeout ( setTime , 3000 ... | Random Colorful letters |
JS | I have a JavaScript application that generates a significant amount of DOM elements . It means that I often use document.createElement ( `` tagname '' ) in my script.I am thinking about using this simple function : I would keep writing my code in JavaScript ( or maybe CoffeScript ) , and use the full document.createEle... | function c ( e ) { return document.createElement ( e ) ; } | Can a minifier do this ? ( ... .and is it a good idea ? ) |
JS | I know how I can find the longest word in a string . For example this code here.But here the problem is that the word `` bbbbbb '' is found because he is theFIRST LONGEST WORD IN THE string , after that with 6 chars we have also the word `` jumped '' . My question is how can I find in this case and the word `` jumped '... | function longestWord ( sentence ) { sentence = sentence.split ( ' ' ) ; let theWord = sentence [ 0 ] ; var longest = 0 ; for ( let i = 0 ; i < sentence.length ; i++ ) { if ( sentence [ i ] ! = `` '' ) { if ( sentence [ i ] .length > theWord.length ) { longest = sentence [ i ] .length ; theWord = sentence [ i ] ; } } } ... | How can I find the longest words in the string and return those ( excluding duplicates ) along with maximum length ? |
JS | I would like to know how can I create textboxes and insert data at page load . What I 'm trying to do is open an array string from a database , create the textboxes and populate the textboxes at page load.I have an array string from an ms sql database that looks something like thisI separated each individual array with... | test , test ; bla ; bla2 ; test44 ; test55 ; test66 < script type='text/javascript ' > // < ! [ CDATA [ $ ( function ( ) { var clone = function ( tmpl ) { return $ ( ( tmpl.clone ( ) ) .html ( ) ) } , $ template = $ ( ' # template_add_form ' ) , formArray = [ clone ( $ template ) ] , // init array with first row $ form... | create textboxes and Insert data at page loading |
JS | I have JSON code : I read that JSON from my script and the output in table is : However I want the output to be equal to that day and its time.For example : Tue 20:00 ( if my timezone is +02 ) | { `` time '' : '' 2015-10-20T11:20:00+02:00 '' } 2015-10-20T11:20:00+02:00 | Convert string into real time date & time |
JS | In the spirit of these two questions : Is it worth the effort to try to reduce JSON size ? JSON response objects : `` pretty '' keys and larger response or short keys and smaller response ? How does a browser handle large arrays of the same object-types , are their keynames somehow compressed in memory ? I once used a ... | [ { `` firstNameAsWrittenInID '' : Pete , `` lastNameAsWrittenInID '' : Jenkins } , { `` firstNameAsWrittenInID '' : Jane , `` lastNameAsWrittenInID '' : Jenkins } , ... { `` firstNameAsWrittenInID '' : Johann , `` lastNameAsWrittenInID '' : Abele } ] [ { `` f '' : Pete , `` l '' : Jenkins } , { `` f '' : Jane , `` l '... | Do browser engines compress keynames in large arrays of reoccurring objects ? |
JS | Possible Duplicate : Can somebody explain this Javascript method ? Any idea why ? | ( x = [ ] .reverse ) ( ) === window // true | Why does this expression return true ? |
JS | The experience I 'm trying to create is one where a background image is first loaded , then an animation is triggered to fade in the element it is attached to . I am doing this in AngularJS using ngAnimate and waitForImages . Specifically , I have the following view in my < body > : Where pageClass is set to landing-pa... | < div ng-view= '' '' ng-class= '' pageClass '' > < br > < br > < br > < h1 id= '' loading-text '' > Loading ... < /h1 > < /div > myModule.controller ( 'LandingPageCtrl ' , [ ' $ timeout ' , ' $ animate ' , function ( $ timeout , $ animate ) { $ animate.on ( 'enter ' , angular.element ( '.ng-scope ' ) , function ( eleme... | Fire $ ngAnimate enter after promise fulfilled |
JS | I want to accomplish the following : setState does n't return anything and the only way I could figure how to do this was calling a callback to my function in the setState callback , however , I 'd prefer doing this with async await if that 's possible . | myFunction = ( ) = > { this.setState ( state = > { const originalBar = state.bar ; return { foo : `` bar '' } ; } , ( ) = > ( { originalBar , newBar : state.foo } ) //return this object ) ; } ; otherFunction = ( ) = > { var originalValue = myFunction ( ) ; //access returned object ( in child component ) } ; | Async return value from setState |
JS | In javascript , I have an array of objects that represents an arbitrarily deep list ... ... where depth is how deep in the list the element is.I want to convert this data into html.For example : becomes ... What is the simplest way to do this , using jQuery ? Thanks | data = [ { title , depth } , { title , depth } , { title , depth } , { title , depth } , ] [ { title : `` one '' , depth : 1 } , { title : `` two '' , depth : 1 } , { title : `` three '' , depth : 2 } , { title : `` four '' , depth : 3 } , { title : `` five '' , depth : 1 } , ] < ul > < li > < p > one < /p > < /li > < ... | Use jquery to generate an arbitrarily deep list |
JS | Can anyone tell me why Please give answer Please Go through the image also Thanks in Advance | 8 > 7 < 6 = true12 > 10 > 2 = false | Can anyone tell me why 8 > 7 < 6 = true ? |
JS | I am trying to populate an array in JavaScript using jQuery . I have some < div > elements in a < section > and I only want the < div > elements that are visible ( via CSS property display : block ) to be added to the array.HTML : JavaScript / jQueryvar mainList = $ ( `` # container div '' ) ; This currently gets ALL <... | < section id= '' container '' > < div > shows up 1 < /div > < div style= '' display : none '' > does n't show 2 < /div > < div > shows up 3 < /div > < div style= '' display : none '' > does n't show 4 < /div > < div style= '' display : none '' > does n't show 5 < /div > < div > shows up 6 < /div > < div > shows up 7 < ... | How to populate a JavaScript array with only the divs that have display : block ? |
JS | This should be a really simple problem , but I ca n't quite figure out what I am doing wrong . I am trying to access the CSS property 'border-bottom ' like this : Unfortunately , after this , temp contains the string `` '' Does anyone know why this is not working or what I should do differently to make it function ? Th... | var temp = $ ( ' # divName ' ) .css ( 'border-bottom ' ) ; | jQuery- .css ( ) not working for an input |
JS | ... but of course it displays perfectly in all other browsers , and of course only IE matters.I 'm aware this type of question has been asked multiple times , but I 've gone through this code definition backwards & forwards and I can not see where there might be any errors . These are the options passed to my highchart... | title : { text : `` } , tooltip : { pointFormat : ' < span style= '' color : { point.color } '' > \u25CF < /span > { point.x : % B % Y } : < b > { point.y } < /b > < br/ > ' } , subtitle : { text : `` } , xAxis : { type : 'datetime ' , title : { enabled : true } , labels : { format : ' { value : % b % Y } ' } , tickLen... | Highcharts line chart wo n't display line chart in IE |
JS | I 'm trying to dynamically insert some list into an element called foos . I want to manually number this list ( e.g . < span > $ { i + 1 } . < /span > for i in the list element number ) but I want the distance between this number and the element to align nicely . By nicely I mean : rather than what is displayed in the ... | 8. foo 9. foo10 . foo11 . foo 8. foo9 . foo10 . foo11 . foo let people = [ 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' , 'foo ' ] ; var htmlString = `` '' ; for ( var i = 0 ; i < people.length ; i++ ) { var person = people [ i ] ; htmlString += ` < span > $ { i + 1 }... | Padding based on size of string ? |
JS | This displays all of them in one click . How do I fix this ? | var sentences = [ 'sentenceone ' , 'another sentence ' , 'another sentence again ' ] ; $ ( `` .btn '' ) .on ( 'click ' , function ( ) { for ( var i=0 ; i < sentences.length ; i++ ) { samplebox.innerHTML += ' < p > '+sentences [ i ] + ' < /p > ' ; } } ) ; | JQuery : How to display an array of paragraph tags one by one on each click ? |
JS | I 'm trying to send some data with Laravel Echo requestI 've seen how to add custom headers to the requestIs there any way to add form-data in a similar way ? EditWhen I inspect the network requests in the DevTools , I can see that there are two formData properties sent by the Echo to the server . So I thought there mu... | window.Echo = new Echo ( { broadcaster : 'pusher ' , key : 'somekey ' , wsHost : '127.0.0.1 ' , wsPort : 6001 , encrypted : false , disableStats : true , forceTLS : false , authEndpoint : 'http : //127.0.0.1:8000/broadcasting/auth ' , 'form-data ' : { // I tried data , dataForm , dataform someData : '123 ' , // this do... | How to add form-data to Laravel Echo request ? |
JS | Suppose I have a function like that : as I know , f1.bind ( 'abc ' ) should create a new function that returns 'abc ' , so I guess it should have output same as which is true , but now the output is false , what 's wrong with my guess ? | var f1=function ( ) { return this ; } ; console.log ( f1.bind ( 'abc ' ) ( ) ==='abc ' ) ; console.log ( 'abc'==='abc ' ) | Why is ( function ( ) { return this } ) .bind ( 'abc ' ) ( ) ==='abc ' equals to false ? |
JS | I have an array of Accept Reject button . if a user clicks on these buttons separate model popup will show . Accept and reject button link has separate data-id and data-action.My aim to write a single javascript function to load the content of the model popup instead of repeating the code of modal.ERB codeAgainst each ... | < % @ non_claim_items.each do |damage_item| % > < tr > < td > < div class= '' input-prepend '' > < span class= '' add-on '' > < % = damage_item.estimated_total_repair_cost.currency % > < /span > < span class= '' uneditable-input input-small currency-format '' > < % = damage_item.estimated_total_repair_cost % > < /span ... | Dynamic content for model popup based on link selected |
JS | I have a PHP populated table from Mysql and I am using JQuery to listen if a button is clicked and if clicked it will grab notes on the associated name that they clicked . It all works wonderful , there is just one problem . Sometimes when you click it and the dialog ( JQuery UI ) window opens , there in the text area ... | $ ( document ) .ready ( function ( ) { $ ( `` .NotesAccessor '' ) .click ( function ( ) { notes_name = $ ( this ) .parent ( ) .parent ( ) .find ( `` .user_table '' ) ; run ( ) ; } ) ; } ) ; function run ( ) { var url = '/pcg/popups/grabnotes.php ' ; showUrlInDialog ( url ) ; sendUserfNotes ( ) ; } function showUrlInDia... | Issue with using a value in JQuery/Javascript |
JS | I have a modified jPlayer with a `` Whats Playing '' info bar.The info bar display echoed info from a PHP file . I need to attach a scroller to the info on that player bar but i cant seem to nail it.The scroller is on a separate js file.http : //www.maxvergelli.com/jquery-scroller/jQuery : The PHP info : | getCurrentTrack ( ) ; $ ( '.now_playing ' ) .SetScroller ( { velocity : 50 , direction : 'horizontal ' , startfrom : 'right ' , loop : 'infinite ' , movetype : 'linear ' , onmouseover : 'pause ' , onmouseout : 'play ' , onstartup : 'play ' , cursor : 'pointer ' } ) ; function getCurrentTrack ( ) { $ ( '.now_playing ' )... | Attach scroller to element in jQuery |
JS | I have a regular expression that works on regexplib.com when I test it with the .NET engine . It does not find a match with JavaScript . I have also tried JSFiddle with the below code . It does not find a match . It returns null.I am trying to use the below javascript in an aspx web page . It does not find any matches ... | var re = RegExp ( '^\d+ ( ? : \.\d { 0,1 } ) ? $ ' ) ; var myString = `` 123 '' ; alert ( myString.match ( re ) ) ; function ValidateData ( ControlObj , ColumnType ) { var re = new RegExp ( '^\d+ ( ? : \.\d { 0,1 } ) ? $ ' ) ; if ( ! ControlObj.value.match ( re ) ) { | regular expression does not work with javascript |
JS | I have recently seen an expression from a source , which looks something like below - Entering this into the Chrome ( Windows 7 , Version 27.0.1453.94 m ) console shows a result of `` 10 '' .Can someone explain what 's happening here ? JSFiddle . | ++ [ [ ] ] [ + [ ] ] + [ + [ ] ] | How does the following piece of expression evaluates to `` 10 '' |
JS | A call to numericInput ( ) , like this : constructs HTML code like this : Then , presumably , in the browser , JavaScript code provided by one of the scripts included in the HTML doc 's header finds that < input > element and renders it with the interactive widget displayed below : I 'm having a hard time , though , fi... | numericInput ( `` obs '' , `` Observations : '' , 10 , min = 1 , max = 100 ) < div class= '' form-group shiny-input-container '' > < label for= '' obs '' > Observations : < /label > < input id= '' obs '' type= '' number '' class= '' form-control '' value= '' 10 '' min= '' 1 '' max= '' 100 '' / > < /div > var numberInpu... | Which JavaScript code implements shiny 's numericInput widget ? |
JS | So i 'm using the soundcloud API to grab favorites from users . Their max limit is 200 per request , however in the end of the object they have an a_href key who 's value is the next page of favorites.Basically , i 'm trying to place a button so that a user can click it and it will feed them the next 200 likes . My iss... | function getAPIURL ( username , subSection ) { apiurl = `` https : //api.soundcloud.com/users/ '' + username + `` / '' + subSection + `` / ? client_id= '' + clientID + limit + `` & linked_partitioning=1 '' } function getFavorites ( ) { titleList.length = 0 ; artistList.length = 0 ; imgList.length = 0 ; idList.length = ... | How can I get the URL for an API if the URL I want is in the API 's JSON ? |
JS | I 'm trying to draw a figure on a canvas , to be filled with a rainbow-colored gradient . The wanted result is something like this : Creating the shape itself is pretty easy , just creating a path and drawing the lines . However , actually filling it with a gradient appears to be somewhat more difficult , as it seems o... | var canvas = document.getElementById ( `` canvas '' ) ; var ctx = canvas.getContext ( `` 2d '' ) ; var gradient=ctx.createLinearGradient ( 0,0,0,100 ) ; gradient.addColorStop ( 0 , 'red ' ) ; gradient.addColorStop ( 0.25 , 'yellow ' ) ; gradient.addColorStop ( 0.5 , 'green ' ) ; gradient.addColorStop ( 0.75 , 'blue ' )... | Complex shape with rainbow gradient |
JS | I 'm trying to override specific function in a library.In my case , I 'm trying to override some functions on Framework7 . The library simply has class called Framework7 , in non ES6 javascript , creating instance of application would look like this : so I assume it 's extendable , so here my code to extends it : the c... | var app = new Framework7 ( ) ; export class Application extends Framework7 { constructor ( options ) { super ( options ) ; } } export class Application extends Framework7 { constructor ( options ) { super ( options ) ; } showPreloader ( title ) { console.log ( 'this not printed : ( ' ) ; super ( title ) ; // this is no... | Overidding library function in es6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.