lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I am trying to implement some unit tests on a form to see if the validation rules are working as expected.from this page : https : //github.com/aurelia/testing/issues/63I found this implementation : https : //github.com/aurelia/validation/blob/master/test/validate-binding-behavior.tsand I tried to implement it in my pr... | import { bootstrap } from 'aurelia-bootstrapper ' ; import { StageComponent } from 'aurelia-testing ' ; import { PLATFORM } from 'aurelia-pal ' ; import { configure , blur , change } from './shared ' ; import { Login } from './login ' ; describe ( 'ValidateBindingBehavior ' , ( ) = > { it ( 'sets validateTrigger ' , ( ... | How to unit test form validation in Aurelia |
JS | i 'm looking for a programmatic way to scrape all available files for a data file series on archive.gov with R. archives.gov appears to use javascript . my goal is to capture the url of each file available , as well as the file 's name.the home mortgage disclosure act data file series has 153 entriesin a browser , i ca... | first_exported_record < - structure ( list ( resultType = structure ( 1L , .Label = `` fileUnit '' , class = `` factor '' ) , creators.0 = structure ( 1L , .Label = `` Federal Reserve System . Board of Governors . Division of Consumer and Community Affairs . ca . 1981- ( Most Recent ) '' , class = `` factor '' ) , date... | how to scrape all files in a catalog series from the national archives ( archives.gov ) with R |
JS | ES5 typeof is considered safe , as it will not throw ReferenceError when checked agains a non-declared value . such ashowever , when checking for typeof undeclaredLetConst in es6 it will throw an error only if the value was later on declared with a let or const . if it was declared with var it will work normally.whats ... | console.log ( typeof undeclaredVar ) ; // undefined console.log ( typeof undeclaredLetConst ) ; let undeclaredLetConst = `` hello '' ; // ReferenceError | ES6 typeof throws an error |
JS | I need to be able to show a `` dynamic return '' for each bet that the user has in place , but for some reason none of them work . I have previously asked this question before , but with no luck.I am hoping that the extra detail in this will be sufficient to help with getting an answer to this at last.I have hard coded... | var count_div = 0 ; $ ( `` div '' ) .each ( function ( ) { count_div++ ; console.log ( `` Counter : `` + count_div ) ; } ) ; for ( var i = 0 ; i < count_div ; ++i ) { $ ( `` # stake- '' + i ) .on ( 'keyup ' , function ( ) { var newVal = ( parseFloat ( $ ( `` # stake- '' + i ) .val ( ) , 10 ) * parseFloat ( $ ( `` # __o... | Work out values from loaded information |
JS | I 'm simply trying to evaluate if an input is a number , and figured isNaN would be the best way to go . However , this causes unreliable results . For instance , using the following method : on these values : shown in this fiddle : http : //jsfiddle.net/4nm7r/1Why does n't isNaN always work for me ? | function isNumerical ( value ) { var isNum = ! isNaN ( value ) ; return isNum ? `` < mark > numerical < /mark > '' : `` not numerical '' ; } isNumerical ( 123 ) ) ; // = > numericalisNumerical ( `` 123 '' ) ) ; // = > numericalisNumerical ( null ) ) ; // = > numericalisNumerical ( false ) ) ; // = > numericalisNumerica... | What causes isNaN to malfunction ? |
JS | Can someone please explain the purpose of double-negating the reverse var in the below code ? The way I understand it , the purpose is to pick the proper index from the [ -1,1 ] array to then use it in the multiplication but it seems to me that [ -1,1 ] [ + ! ! reverse ] ; could be safely replaced by [ -1,1 ] [ +revers... | return function ( a , b ) { var A = key ( a ) , B = key ( b ) ; return ( ( A < B ) ? -1 : ( A > B ) ? +1 : 0 ) ) * [ -1,1 ] [ + ! ! reverse ] ; } | Meaning of [ -1,1 ] [ + ! ! boolean_var ] |
JS | Just to be clear , a class that inherits DynamicObject ( in C # of course ) is not the same concept as JavaScript 's variables being dynamic . DynamicObject allows the implementer to programmatically determine what members an object has , including methods.Edit : I understand that JavaScript objects can have any member... | public class SampleObject : DynamicObject { public override bool TryGetMember ( GetMemberBinder binder , out object result ) { result = binder.Name ; return true ; } } dynamic obj = new SampleObject ( ) ; Console.WriteLine ( obj.SampleProperty ) ; //Prints `` SampleProperty '' . myAPI.uploadSomeData ( data1 , data2 ) | JavaScript equivalent of C # 's DynamicObject ? |
JS | I am building a JavaScript array , which has strings as keys.The array should have an object at every entry . My object looks like this ( a console.log of my variable rIds ) : Now , the length of this object is 0 , which makes it impossible to iterate it.I want to iterate every key , so I can retrieve and access my lis... | var rIds = [ ] ; var response = RR.data.JSON.placements ; console.log ( response ) ; $ ( response ) .each ( function ( placementId ) { var placement_name = this.placement_name ; rIds [ this.placement_name ] = { productIds : [ ] } ; $ ( this.recs ) .each ( function ( recIndex ) { var pid = this.pid ; pid = getRandomId (... | Iterating JavaScript object with strings as keys |
JS | One problem with the standard mouseout event is that it fires not only when the cursor leaves the region of the screen bounded by the element 's external perimeter , but also when the cursor hovers over some other element contained within this perimeter.The rationale for jQuery 's mouseleave event is to signal only the... | < div id= '' b-div '' > < div id= '' d-div '' > < span > d < /span > < /div > < /div > < div id= '' c-div '' > < span > c < /span > < /div > $ ( ' # b-div ' ) .bind ( { mouseenter : function ( ) { $ ( this ) .addClass ( 'outlined ' ) ; } , mouseleave : function ( ) { $ ( this ) .removeClass ( 'outlined ' ) ; } } ) ; | How to achieve mouseleave effect with absolutely-positioned non-descendants ? |
JS | For example , I have read this article by David Walsh : https : //davidwalsh.name/customeventAs the author summarizes at the end of the article : Creating and trigger custom events with custom data is incredibly useful . Not only can you create your own naming convention for events , but you may also pass custom data a... | // Trigger it ! myElement.dispatchEvent ( myEvent ) ; | How are custom events in JavaScript different from simply calling regular functions ? |
JS | I found the following weird behavior while working on JavaScript numbers.What is happening here ? I understand that JavaScript can only represent numbers upto 2^53 ( they are internally 'double ' ? ) , but why this behavior ? If 2^53 is the practical max , then why do we have Number.MAX_VALUE ( 1.7976931348623157e+308 ... | var baseNum = Math.pow ( 2 , 53 ) ; console.log ( baseNum ) ; //prints 9007199254740992console.log ( baseNum + 1 ) ; //prints 9007199254740992 again ! console.log ( baseNum + 2 ) ; //prints 9007199254740994 , 2 more than +1console.log ( baseNum + 3 ) // prints 9007199254740996 , 2 more than +2console.log ( baseNum + 4 ... | Strange JavaScript Number behavior |
JS | Why is it that these two seemingly identical pieces of code behave differently in Javascript and Lua ? Lua : Javascript : The example in Lua prints 0 1 2 3 4 5 6 7 8 9 , but the example in Javascript prints 10 10 10 10 10 10 10 10 10 10 . Can anybody explain the difference between closures in Javascript and Lua that ca... | function main ( ) local printFunctions= { } local i , j for i=1,10 do local printi = function ( ) print ( i ) end printFunctions [ i ] =printi end for j=1,10 do printFunctions [ j ] ( ) endendmain ( ) function main ( ) { var printFunctions= [ ] var i , j ; for ( i=0 ; i < 10 ; i++ ) { var printi = function ( ) { consol... | Difference in Closures between Javascript and Lua |
JS | I Have An Input type text as Following CodeAnd I use those inputs value as followFor Example IfNow What i want is to combine all input value to one . for that i refer this link . but did n't get any exact idea for this.also hearse about jQuery.merge ( ) but not helpful or not understand . So how can i do this ? | < input type= '' text '' minlength= '' 1 '' maxlength= '' 1 '' class= '' myinputs '' name= '' myinputs [ ] '' > < input type= '' text '' minlength= '' 1 '' maxlength= '' 1 '' class= '' myinputs '' name= '' myinputs [ ] '' > < input type= '' text '' minlength= '' 1 '' maxlength= '' 1 '' class= '' myinputs '' name= '' my... | Combine Array From Html To Jquery |
JS | In my project I need to display 2 different components in 2 different screens . So I open two browser windows and display those components.I was wondering if it 's possible to interact from a component in the first window to another in the second one ? I tried creating a Subject in a Service . but whenever I try to sub... | export class MyService { public navigationTrigger : Subject < NavigationParams > = new Subject ( ) ; constructor ( private _http : Http ) { this.navigationTrigger.next ( params ) ; } } this.watsonService.navigationTrigger.subscribe ( ( navigation ) = > { this.updateNavigation ( navigation ) ; } ) ; | Interact with a component opened in another window |
JS | Whenever i add inline css with jQuery it will also change the format of the inline css which is already there . For example if i have a background image without any quotes in the url and i will add something likeit will re-format the complete inline css . ( also for example background-color : # ffffff ; transfers to - ... | $ ( '.element ' ) .css ( 'padding ' , '10px ' ) ; | Avoid double quotes in jQuery inline css |
JS | JavaScript is returning X - Y , where X and Y are Real numbers and their sum is negative , instead of just the negative sum . I 've tried an if else statement using where the if statement just had a `` - '' in front of the value to concatenate the string `` minus '' character in front of the number and the else stateme... | if ( Math.sign ( function ) < 0 ) else function velocity_final ( initial_velocity , acceleration , time ) { var initial_velocity = prompt ( 'Please enter the Initial Velocity in Meters per Second ' ) ; var acceleration = prompt ( 'Please enter the acceleration in Meters per Second Squared ' ) ; var time = prompt ( 'Ple... | Is there a way to force JavaScript to return a negative value in an alert box ? |
JS | The Angular 1.6 's $ http.jsonp does not play nice with the google sheets ' API : I 'm trying to fetch and then get my data from google sheets , with the following : I successfuly manged to get the data from the sheets , by using a function ( callback ) , with a vnila js , by when I tried with angular , I got an `` goo... | var callback ; app.controller ( `` meetingsTable '' , function ( $ scope , $ http , $ sce ) { var url = `` http : //spreadsheets.google.com/a/google.com/tq '' ; var trustedUrl = $ sce.trustAsResourceUrl ( url ) ; var key = 'MY_KEY ' ; var tq = 'select % 20* % 20limit % 2010 ' ; var tqx = 'responseHandler : callback ' ;... | Angular 1.6 $ http.jsonp while using the google sheets API |
JS | I 'm using Evaporate.js to upload files to S3 . I 've had everything working , until I decided to enable server side encryption.According to the S3 docs , you can enable it by passing a header . So I updated my add code to look like : I get the error : DOMException : Failed to execute 'setRequestHeader ' on 'XMLHttpReq... | var promise = _e_.add ( { name : name , file : files [ i ] , started : callback_methods.started , complete : callback_methods.complete , cancelled : callback_methods.cancelled , progress : callback_methods.progress , error : callback_methods.error , warn : callback_methods.warn , paused : callback_methods.paused , paus... | Bad XMLHttpRequest when uploading to S3 |
JS | Let 's say i have some bit of JavaScript which will modify the DOM , perhaps hide/show a form field or something like that and let 's assume I want to execute this task on multiple pages , but only once or twice per page.Is it better to encapsulate this functionality into a jQuery plugin , or a vanilla JavaScript funct... | jQuery.fn.toggleFormInput = function ( ) { // Stunning JavaScript/jQuery magic here } function toggleFormInput ( ) { // Stunning JavaScript/jQuery magic here } | Is it better to encapsulate functionality in a jQuery plugin or vanilla JavaScript function ? |
JS | I got the following insistent JS issue just for IE 8-9 , in other browsers my code working very well . Case : I have the following code in JS , which should start some server process and update progress bar with status on server side , what Jquery UI provide : In StartLongProcess method in current controller I starting... | $ ( `` # btnSendUser '' ) .click ( function ( event ) { $ .ajax ( { type : `` POST '' , url : `` /StartLongProcess '' , dataType : `` json '' , traditional : true , data : { userIds : users } , success : function ( result ) { console.log ( `` Process start '' ) ; } } ) ; var processId = 0 ; getStatus ( processId ) ; } ... | IE 8-9 JavaScript issue with long loop |
JS | according to MDN , when using the unary plus operator : Integers in both decimal and hexadecimal ( `` 0x '' -prefixed ) formats are supported . Negative numbers are supported ( though not for hex ) . If it can not parse a particular value , it will evaluate to NaN.But when I run this Jasmine test ( the toBe ( ) matcher... | it ( `` should return NaN when trying to convert a string representing a NEGATIVE HEX to the corresponding number '' , function ( ) { var a = '-0xFF ' ; expect ( typeof +a ) .toBe ( 'number ' ) ; expect ( isNaN ( +a ) ) .toBeTruthy ( ) ; //Fails on Chrome and Opera ... } ) ; | Behavior of JS unary plus operator applied on a string representing a negative hex |
JS | I have an input form , with a submit button . I do n't want the user to be able to double click the submit button and double submit the form ... So I have added the following jQuery to my Form : The above code stores the submit time and prevents the second submit , if it is too early ( less than 2 seconds ) , I do n't ... | var prevSubmitTime = new Date ( '2000-01-01 ' ) ; function preventFromBeingDoubleSubmitted ( ) { $ ( 'form ' ) .each ( function ( ) { $ ( this ) .submit ( function ( e ) { if ( $ ( `` form '' ) .valid ( ) ) { var curSubmitTime = new Date ( $ .now ( ) ) ; // prevent the second submit if it is within 2 seconds of the fir... | How are jQuery event handlers queued and executed ? |
JS | I am configuring angularjs project dependecies using requirejsfollowing are the configurationsRuntime dependencies are , In cornerstone.js I am loading the modules in a following way , I am getting the following error , myApp.js:2312 Uncaught ( in promise ) ReferenceError : cornerstone is not definedat line define ( ``... | `` cornerstone-core '' : '' emp/cornerstone.min '' , '' cornerstone-math '' : '' emp/cornerstoneMath.min '' , '' hammer '' : '' emp/hammer.min '' , '' properties '' : '' emp/properties '' '' clientParameters '' : '' emp/clientParameters '' '' cornerstone '' : '' emp/cornerstone '' '' cornerstoneMath '' : '' emp/corners... | requirejs not loading the object properly |
JS | I 'm working on a Node module , and am trying to pass an instance of a class that subclasses ObjectWrap as an argument to a JavaScript callback.In other places I 've been able to successfully unwrap JavaScript objects to the same class , using : How might I do the reverse ? I want to pass an instance of GitCommit to a ... | GitCommit *commit = ObjectWrap : :Unwrap < GitCommit > ( args [ 0 ] - > ToObject ( ) ) ; Local < Value > argv [ ] = { // Error code Local < Value > : :New ( Integer : :New ( 0 ) ) , // The commit commit // Instance of GitCommit : ObjectWrap } ; // Both error code and the commit are passed , JS equiv : callback ( error ... | How to pass object to JavaScript callback in V8 |
JS | Clearly this snippet will crash at line 8 . If you parse this with Opal , you will get this compiled code : And of course it will throw the same error.However , is there a way to determine the Ruby line where this error comes from ? I can see this question : Is there a way to show the Ruby line numbers in javascript ge... | class Test def initialize end def crash print x endendTest.new.crash /* Generated by Opal 0.8.0.beta1 */ ( function ( Opal ) { Opal.dynamic_require_severity = `` error '' ; var self = Opal.top , $ scope = Opal , nil = Opal.nil , $ breaker = Opal.breaker , $ slice = Opal.slice , $ klass = Opal.klass ; Opal.add_stubs ( [... | Get the error line in a Ruby Opal code |
JS | I have read the throttleTime documentation , but I do n't get the operator fully.I know how throttleTime ( 1000 ) works . After an event arrives it will skip all subsequent events for 1 second and then start this process again.What I have trouble to understand is how exactly ThrottleConfig works , which is the third pa... | throttleTime < T > ( duration : number , scheduler : SchedulerLike = async , config : ThrottleConfig = defaultThrottleConfig ) : MonoTypeOperatorFunction < T > | How does throttleTime operator 's config parameter work ? ( ThrottleConfig ) |
JS | I 'm a JS developer and use self-executing anonymous functions routinely to minimize pollution of the global scope.ie : ( JS ) Is the same technique possible / advisable in PHP to minimize function / variable name clashes ? ie : ( PHP ) | ( function ( ) { var x = ... } ) ( ) ; ( function ( ) { $ x = 2 ; function loop ( $ a ) { ... } loop ( $ x ) ; } ) ( ) ; | Wrapping variables in anonymous functions in PHP |
JS | Can one override core provider like $ templateCache while maintaining reference to the original provider ? I 'd like to override $ templateCache to be case insensitive.I.E . something likeBut less hacky , more DI-style ? | var normalGet = $ templateCache.get ; var normalPut = $ templateCache.put ; $ templateCache.get = function ( key ) { normalGet ( key.toLowerCase ( ) ) ; } ; $ templateCache.put = function ( key , value ) { normalPut ( key.toLowerCase ( ) , value ) ; } ; | Override $ templateCache to be case insensitive |
JS | I 'm learning JS and I would greatly appreciate your help . I would like to us higher order functions and callbacks if possible.TaskDeclare these local variables and make them equal to the appropriate information , firstName , LastName , linkedIn , phone , city.Using string concatenation , make a local variable fullNam... | ( function person ( ) { var firstName = `` Rob '' , lastName = `` Johnson '' , fullName = firstName + `` , `` + lastName , linkedIn = 'https : //www.linkedin.com/in/robjohnson ' , phone = 3105559288 , city = 'Los Angeles ' , info = [ firstName , linkedIn , phone , city ] , education = [ 'UWRock ' , 'Generals ' , '2017 ... | How do you return an object from a function ? |
JS | I 'm having trouble resolving a scope issue with my javascript.I have an array , dog [ ] that is defined from JSON , that I need access to from inside a nested function.when I dont pass dog into the click function : i get : Does anyone have any suggestions to get the array with every element passed into the click funct... | function blah ( json ) { for ( var u = 0 ; u < json [ 0 ] [ 1 ] [ u ] .length ; u ++ ) { var dog = ' k ' + json [ 0 ] [ 1 ] [ u ] .doggies ; console.log ( dog ) ; // prints array of doggie strings $ ( ' # puppy ' ) .click ( function ( dog ) { // dog is passed in the function console.log ( dog ) ; // Syntax error , unre... | Javascript variable scope question |
JS | I 'm trying to write a function that , given an array and n , returns the array with elements repeating no more than n times . I can not change the order of the array.Below is the code I have so far . What is perplexing me is that it works for most elements in a given array , but not for some others . I 'm trying to fi... | function deleteNth ( arr , n ) { arr.forEach ( function ( item , index ) { var count = 0 ; for ( var i = 0 ; i < arr.length ; i++ ) { if ( arr [ i ] === item ) { count++ ; while ( count > n ) { var remove = arr.lastIndexOf ( item ) ; arr.splice ( remove , 1 ) ; count -- ; } } } } ) ; return arr ; } var x = deleteNth ( ... | Changing an array in place using splice ( ) |
JS | I encounter an issue in Angularjs when using nested ng-include with the $ compile function.Here is the error : I think , I have to inject the $ rootElementProvider somewhere in the compile flow but I do not know how.Here is a Plunker of my issue : http : //plnkr.co/edit/K8iayGXGLx5QwHNNiLZ1 ? p=previewAll the code is n... | Error : [ $ injector : unpr ] Unknown provider : $ rootElementProvider < - $ rootElement < - $ location < - $ anchorScroll < - ngIncludeDirective | Angular issue with nested ng-include |
JS | I 'm trying to call the Javascript variable elem after LIKE in the SQL statement so that the input text is used there . However the way I 'm doing it does n't work with the Sheetrock library I 'm using ( http : //chriszarate.github.io/sheetrock/ ) . | < ! DOCTYPE html > < html > < body > Enter Tracking Code : < input type= '' text '' id= '' textbox_id '' > < input type= '' button '' value= '' Submit '' > < table id= '' switch-hitters '' class= '' table table-condensed table-striped '' > < /table > < script src= '' https : //cdnjs.cloudflare.com/ajax/libs/jquery/2.1.... | How to use LIKE operator in Sheetrock |
JS | I noticed that Google Closure Compiler did not rename document to something like d to reduce space.I can not think of a case where this would break the code ( ie where document points to something else down the road ) . Actually the same goes for window.Is there a reason for protecting document this way ? == EDIT ==By ... | var d=document ; var obj1=d.getElementById ( `` obj1 '' ) ; var obj2=d.getElementById ( `` obj2 '' ) ; ... // with enough uses of document so it makes to reassign it size-wise . | Is it safe to rename document variable in javascript |
JS | I 'm trying to build a Safari Extension where when a user hits Command+B it will show the popover . Using the code below it works but always shows the popover on a different window not the current window/tab . I would like it to display the popover on the current window instead of switching to a different window and op... | < script > safari.application.addEventListener ( 'message ' , function ( e ) { if ( e.name == 'Show Popover ' ) { safari.extension.toolbarItems [ 0 ] .showPopover ( ) ; } } , false ) ; < /script > document.addEventListener ( `` keydown '' , keydown ) ; function keydown ( event ) { if ( event.metaKey & & event.keyCode =... | Safari Extension Showing Popover Different Window |
JS | I am working with a testing project , where I am writing a pure Javascript Jasmine Karma setup to test a pre-compiled Typescript setup . However , I can not get the test cases to start . I can see the console messages that come from compiled typescript within the console fire alright , but it simply will not start the ... | define ( `` testName '' , [ `` component/to/test '' ] , function ( component ) { describe ( `` testing module '' , function ( ) { it ( `` should work '' , function ( ) { expect ( true ) .toEqual ( true ) } ) ; } ) } var requirejs , require , define ; ( function ( global ) { define ( `` component/to/test '' [ `` depend ... | Jasmine tests case not launching within define in compiled Typescript |
JS | Please take a look at the screenshot given belowAs you can see in the screenshot above there are # 3 watchers for a single binding.Can anyone please elaborate why is it so ? P.S : I am using AngularJS Batarang for checking the performance . | var app = angular.module ( 'app ' , [ ] ) ; app.controller ( 'appCtrl ' , function ( $ scope , $ timeout ) { $ scope.name = 'vikas bansal ' ; } ) < ! DOCTYPE html > < html lang= '' en '' > < head > < meta charset= '' UTF-8 '' > < title > Document < /title > < script src= '' http : //ajax.googleapis.com/ajax/libs/angula... | Angularjs : why there are 3 watchers for 1 binding ? |
JS | I 'm currently trying to establish a technique to verify some data from my server , for a simple Javascript game . I understand that there are many issues with trying to protect your Javascript application as , by definition , all of the code is available client-side . For example , as it 's a game , if : to stop peopl... | var playerScore = 100 var playerScore = 10000000 | Ensuring retrieved JSON is validated from the correct server for Javascript games |
JS | I happen to read about XSS and how to avoid it . From what I have read , I came to know that we need input filtering , proper handling of application code and output encoding to make the web application somewhat XSS safe . After going through several articles , several doubts still persist . When I tried jQuery.text ( ... | function copyData ( ) { var divValue = jQuery ( `` # divName1 '' ) .html ( ) ; jQuery ( `` # divName2 '' ) .html ( divValue ) ; /XSS Here } | Some clarifications regarding XSS |
JS | I 've created a very basic service worker , that logs the request headers on fetch event : On the main page , I 'm fetching the same page like so : When logging the headers I 'm getting just the following 2 headers : Why ca n't I see any other/custom headers ? Is it a security limitation ? | self.addEventListener ( 'fetch ' , event = > { console.log ( `` - Fetch - '' ) ; for ( const pair of event.request.headers.entries ( ) ) { console.log ( pair [ 0 ] + ' : '+ pair [ 1 ] ) ; } } ) ; function fetchPage ( ) { fetch ( location.href ) ; } - Fetch -service-worker.js:12 accept : */*service-worker.js:12 user-age... | Reading request headers inside a service worker |
JS | Does any compressor take care of removing the switch cases which do not get called anywhere in the application ? If the above is all I have , then theoretically cases 0,2,3 are dead code and will never be executed . Does any compressor have the intelligence of removing this code when minifying code ? I am taking a look... | function execute_case ( id ) { switch ( id ) { case 0 : console.log ( `` 0 '' ) ; break ; case 1 : console.log ( `` 1 '' ) ; break ; case 2 : console.log ( `` 2 '' ) ; break ; case 3 : console.log ( `` 3 '' ) ; break ; default : console.log ( `` default '' ) ; break ; } } execute_case ( 1 ) ; | Dead code removal from switch cases in JavaScript |
JS | If I try to parse a date with this syntax : it will return 1 March 2013.it will return 2 March 2013 . But if I doit will return Invalid Date.My point is , why do n't all of these dates return Invalid Date ? | var date1 = new Date ( Date.parse ( '2013 ' + '/ ' + '02 ' + '/ ' + '29 ' ) ) ; var date1 = new Date ( Date.parse ( '2013 ' + '/ ' + '02 ' + '/ ' + '30 ' ) ) ; var date1 = new Date ( Date.parse ( '2013 ' + '/ ' + '02 ' + '/ ' + '33 ' ) ) ; | Inconsistent determination of valid dates using Date.parse |
JS | When I run jest -- coverage jest only collects coverage from JavaScript files , but not my vue files . The folder structure is correct . jest.config.js is in the root folder , just like /components and /lib . For me , there is no logical explanation why coverage is collected from JavaScript files but not from vue files... | module.exports = { verbose : true , setupFilesAfterEnv : [ ' < rootDir > /test-framework-scripts.js ' ] , moduleFileExtensions : [ 'js ' , 'jsx ' , 'json ' , 'vue ' , 'node ' , ] , moduleNameMapper : { '^ @ / ( . * ) $ ' : ' < rootDir > / $ 1 ' , } , moduleDirectories : [ 'node_modules ' , 'bower_components ' , 'shared... | Jest does not collect coverage from vue files ( nuxt ) |
JS | i have an issue . How can i clone an existing div with jquery ? [ Image ] 1I need to clone the div with id= '' contenido '' when someone press the button with class= '' agregar_producto '' .How can i solve it ? [ Example ] 2Is it possible ? i need only an example to solve my problem.Thx you ! < 3EDIT : If a clone this ... | < div class= '' modal-body '' > < div class= '' row '' > < div class= '' col-md-5 text-center '' > < b > N & uacute ; mero Factura < /b > < input type= '' number '' class= '' form-control '' id= '' numero '' > < br/ > < /div > < div class= '' col-md-2 text-center '' > -o- < /div > < div class= '' col-md-5 text-center '... | clone existing div with Jquery |
JS | Could someone explain this to me ? It seems to me that diagramImage does not exist until the Kinetic constructor returns , but I am able ( and seem to need to ) assign context 's strokeStyle to diagramImage 's color -- before diagramImage has been created ? Why does this work ? EDIT : Full code : | var diagramImage = new Kinetic.Shape ( function ( ) { var context = this.getContext ( ) ; context.beginPath ( ) ; context.lineWidth = 1 ; //This is crazy tricks . It 's part of the KineticJS demo website , but how am I able to assign diagramImage.color here ? context.strokeStyle = diagramImage.color ; var lastVertice =... | I seem to be using a variable before it is fully created in Javascript , but this works -- why ? |
JS | I have a jsfiddle code to record the time and location of a click on an image . It works fine on any desktop platforms but scrolling and highlighting chunks of the text don ’ t work on iPad in chrome or safari . So as a workaround , I 'd like to be able to copy the list of clicks and times that the javascript generates... | < ! -- Image Map Generated by http : //www.image-map.net/ -- > < img src= '' https : //hecoira.leeds.ac.uk/wp-content/uploads/sites/164/2019/08/0D174AF3-1221-42A4-878E-305FD6D829BF-e1564773811882.jpeg '' usemap= '' # image-map '' > < map name= '' image-map '' > < area target= '' '' alt= '' IVStand '' title= '' IVStand ... | How to copy text generated by JavaScript ? |
JS | I found one very good example of Collapsible Content on Internet but it 's unfinished.How I can expand or hide the answer from the example when I click on the row ? | < div class= '' container faq_wrapper '' > < div class= '' row '' > < div class= '' span10 offset1 '' > < p > & nbsp ; < /p > < div class= '' faq-all-actions '' > < a class= '' faq-expand '' onclick= '' jQuery ( '.answer-wrapper ' ) .css ( 'display ' , 'block ' ) ; '' > Expand All < /a > & nbsp ; & nbsp ; | & nbsp ; & ... | Collapse row on mouse click |
JS | What I 'm trying to achieve is to read the current word at the caret position.Example : Hello| - > returns HelloHel|lo - > returns HelloI have put the code inside an event handler which is onKeyup inside an if statement : When this is executed , it returns the current word , but the text area loses the focus.JsfiddleHo... | if ( e.keyCode === 37 || e.keyCode === 39 ) { console.log ( $ ( this ) .getWord ( ) ) ; } | Textarea loses focus when calling a function |
JS | I ran into a weird thing while trying to use String methods with higher-order functions . This will throw an error : I have to wrap the predicate in another function to make it work . But is n't 'boo'.includes already a function ? This works with plain functions : Is there some special property of String methods that p... | [ ' a ' , ' b ' ] .some ( 'boo'.includes ) const boo = { includes : ( ) = > true } ; [ ' a ' , ' b ' ] .some ( boo.includes ) | String methods with higher-order functions |
JS | Given the following test code : This code should run asynchronously , but it blocks all interaction with the page . Why ? This was tested in Chrome 44 , according to this table Promises should be fully implemented . Fiddle here ( warning : blocks the tab ) | var p = new Promise ( function ( resolve , reject ) { for ( var i=0 ; i < 10000000 ; ++i ) for ( var y=i ; y < 10000000 ; ++y ) z = i + y ; resolve ( ) ; } ) ; p.then ( function ( ) { alert ( `` resolved '' ) ; } ) ; | ES6 Promise blocks page |
JS | This is the image of the index on the left on Mozilla Developer Network . What I would like to ask is this : What is the difference between Document and document ? The reason why I am asking is this : I have always retrieved elements as follows ( document with a small d ) : and MDN lists it as follows ( Document with a... | document.getElementById ( `` # id '' ) ; Document.getElementById ( `` # id '' ) ; | What is the difference between Document and document ? |
JS | I am trying to load google map on JavaFx-WebView , and it does n't show anything except background color of html body that i have coded on html file.Also i tried some examples on Google search , all the result were older . None of it works.My Java version is `` 1.8.0_121 '' I wrote a html file & run it . It loaded goog... | # map_canvas { height : 100 % ; background-color : blue ; } function initialize ( ) { var latlng = new google.maps.LatLng ( 37.39822 , -121.9643936 ) ; var myOptions = { zoom : 14 , center : latlng , mapTypeId : google.maps.MapTypeId.ROADMAP , mapTypeControl : false , navigationControl : false , streetViewControl : fal... | Does new versions of google map 's javascript versions work on JavaFx-WebView |
JS | I have audio/videos that you can play in a portfolio area on my website.If I play one of them , and then go the previous page , and then back to my page using next button of my browser , the audio will play automatically even though I did n't click on anything.The exact same behaviour will occur if I play a video or au... | < iframe class= '' ms-slide-video '' src= '' about : blank '' allowfullscreen= '' true '' style= '' width : 100 % ; height : 100 % ; display : none ; '' > < /iframe > < iframe class= '' ms-slide-video '' src= '' /dacontent/video/mp4/2205.mp4 ? & amp ; autoplay=1 '' allowfullscreen= '' true '' style= '' width : 100 % ; ... | Audio file plays automatically when going back to the previous page |
JS | I 'm using React Table ( React Bootstrap Table-2 ) to display a table in a page and populate it with data from an database API . I want to make the values displayed in one of the columns as links ( hrefs ) . This particular column contains only URLs . What i 'm trying to achieve is that , If i click on the url ( `` sho... | { datafield : `` report '' , text : `` Show report '' , accessor : `` link '' , Cell : ( e ) = > < a href= { e.value } > { e.value } < /a > } , import React , { useState , useEffect } from `` react '' ; import logo from `` ./logo.svg '' ; import `` ./App.css '' ; import axios from `` axios '' ; import BootstrapTable fr... | How to make a Column data clickable one in React table ? |
JS | I need to wrap adjacent elements with the same class in a div using jQuery . So far I 'm using .wrapAll function to wrap elements with the same class in a div.HTML : Script : Output : However I need to wrap the adjacent elements with 'image ' class in separate divs with 'galley ' class . So the output needs to look lik... | < a class= '' image '' > < /a > < a class= '' image '' > < /a > < a class= '' image '' > < /a > < p > Some text < /p > < a class= '' image '' > < /a > < a class= '' image '' > < /a > $ ( `` a.image '' ) .wrapAll ( `` < div class='gallery ' > < /div > '' ) ; < div class='gallery ' > < a class= '' image '' > < /a > < a c... | Wrap adjacent elements with the same class |
JS | The distinction between tasks and microtasks is important because IndexedDB transactions commit across tasks , but not microtasks . This is problematic when wrapping IndexedDB code in Promises , because in Firefox ( and maybe other browsers ) , promise resolution does not happen in a microtask , so your transaction wil... | var immediate = require ( 'immediate ' ) ; var openRequest = indexedDB.open ( 'firefox-indexeddb-promise-worker-test ' ) ; openRequest.onupgradeneeded = function ( ) { var db = openRequest.result ; var store = db.createObjectStore ( 'whatever ' , { keyPath : 'id ' } ) ; store.put ( { id : 1 } ) ; store.put ( { id : 2 }... | Microtasks inside Web Workers |
JS | I 'm having tough time figuring out why this is happening , but essentially Redux Promise was working fine for me while returning something like : However , I now need to pass another information with it like soThis results in an unresolved promise instead of data . I tried renaming order to something like position or ... | return { type : STORY_ACTIONS.STORY_SPOTIFY_REQUEST , payload : request } return { order : 0 , // New field type : STORY_ACTIONS.STORY_SPOTIFY_REQUEST , payload : request } | Why does Redux Promise return unresolved promise if more than type and payload options are specified ? |
JS | I 'm having a problem using the jquery hover events . I 've created a reduction of the problem . You can find a working demonstration here . I can reproduce this after moving the mouse around in IE , FF , Opera , and Chrome.I 'm using queued animations in my mouseover event . Roughly 1 % of the time , the color of the ... | function ani ( ) { $ ( 'td ' ) .stop ( ) .animate ( { backgroundColor : ' # 0f0 ' } , 3000 ) .animate ( { backgroundColor : ' # 00f ' } , 3000 ) ; } | JQuery color animations not firing reliably |
JS | I have a requirement that the user can provide arbitrary statements which can be stored in a function and called later to get a return value . A simple example of this is that userInput might beI would store this viaand then running callback ( ) returns 10 as expected.However , I also need to support the case with an e... | var x = 10 ; x ; var callback = function ( ) { return eval ( userInput ) ; } var x = 10 ; return x ; var callback = new Function ( userInput ) ; if ( envVar < 10 ) return a ; b * 0.5 ; var x = 10 ; switch ( x ) { case 10 : 100 ; break ; default : 200 ; break ; } | Get a return value from arbitrary eval 'd code |
JS | This is the function : It works for small numbers , but when the number is large , throws an exception saying invalid array length . I can not understand what 's going on here . What does the RegEx test do ? Why does this code work ? | var isPrime = function ( x ) { return ( ! ( /^ , ? $ |^ ( , ,+ ? ) \1+ $ /.test ( Array ( ++x ) ) ) ) ; } ; | How does this weird JavaScript function for primality check work ? |
JS | There seems to be an issue with the prototype event registry after the 1.7.3 update , I was using prototype_event_registry on the element storage to access click events so that i could replay them.This is so that I can stop events and optionally resume them based on a callback , everything was working fine , but after ... | /** * creates a toggling handler for click events taking previous click events into account . * * w.r.t stopping of a click event , handles cases where the button is a submit or a normal button . * in the case of a submit , calling < tt > Event.stop ( ) < /tt > should be sufficient as there are no other listeners on th... | PrototypeJS Event Registry Issues |
JS | Is there is way to compress JavaScript code ? e.g.after compression it should be Also , I need vise versa at the time of editing the code . | function test ( ) { // some code here } function test ( ) { //some code here } | JavaScript code compression |
JS | How can I run a piece of code as soon as a form has been reset ? The reset event fires before the form fields get reset to their default values . So , for example : This wo n't work . ( Demo ) As the reset event fires before the browser handles the default form reset behavior , the code above simply sets the input 's v... | $ ( 'form ' ) .on ( 'reset ' , function ( e ) { $ ( 'input ' ) .val ( ' a value that should be set after the form has been reset ' ) ; } ) ; $ ( 'form ' ) .on ( 'reset ' , function ( e ) { setTimeout ( function ( ) { $ ( 'input ' ) .val ( 'yay it works now ' ) ; } , 0 ) ; } ) ; $ ( 'form ' ) .on ( 'reset ' , function (... | Execute code as soon as form has been reset |
JS | I was searching for a suitable explanation for this on SO , but could n't find the one which answers my question.I read that in JavaScript , Objects could n't be deleted . So to find out , I was playing around in my browser 's console . I created an object like this : Then I did delete a.x which returned true . ( No su... | var a = { x:10 } ; | JavaScript delete objects behaves differently in different browsers |
JS | Well the title says it all , I 'm trying to write a script ( that runs in a nodejs/express server-side application ) that leverages libraries request , unzip and xml2js to perform a task consisting of fetching a zip file from a given url , whose content is an xml file which I need to parse to a javascript object for so... | var express = require ( `` express '' ) ; var app = express ( ) ; /* some init code omitted */var request = require ( `` request '' ) ; var unzip = require ( `` unzip '' ) ; var xml2js = require ( `` xml2js '' ) ; var parser = new xml2js.Parser ( ) ; app.get ( `` /import '' , function ( req , res ) { request ( `` http ... | Nodejs : wget , unzip and convert to js without writing to file |
JS | I am trying to render my nested ( can be multiple level ) JSON using Mustache partials . It renders only till second level it does not third & greater . As per definition partials can be used to render recursively . Am I doing it wrong ? or is there any other way to achieve the same using mustache ? JS Bin Template : D... | < script id= '' product-list '' type= '' x-tmpl-mustache '' > < ul class='products ' > { { # product } } < li class='product ' > { { productName } } < /li > { { > recurse } } { { /product } } { { ^product } } < li class='empty ' > No products Available < /li > { { /product } } < /ul > < /script > < script id= '' recurs... | MustacheJS rendering nested JSON using partials |
JS | I am new to javascript and I am attempting to create a simple form validation . When I hit the submit button nothing happens . I have been looking at examples for a while and I can not seem to figure out where I am going wrong . Any suggestions : Right after this post I am going to break it all down and start smaller .... | < form name= '' form '' action= '' index.html '' onsubmit= '' return construct ( ) ; '' method= '' post '' > < label > Your Name : < span class= '' req '' > * < /span > < /label > < input type= '' text '' name= '' name '' / > < br / > < label > Company Name : < span class= '' req '' > * < /span > < /label > < input typ... | JavaScript no response with validation |
JS | ProblemStyles are not being updated when the last-child changes due to extra elements being added dynamically with JavaScript.ExampleClick `` Add more blocks '' in the snippet below . When the new blocks are added the fourth .block element ( `` Test block 4 '' ) will not have a bottom red border even though it is no lo... | $ ( `` # addMore '' ) .one ( `` click '' , function ( ) { $ ( `` # container '' ) .append ( $ ( `` # container '' ) .html ( ) ) ; $ ( this ) .remove ( ) ; } ) ; .block { border-bottom : 1px solid red ; counter-increment : block ; margin : 20px 0 ; position : relative ; } .block : after { content : `` `` counter ( block... | Chrome not updating styles when last-child changes |
JS | Is there a way to write a Typescript definition for an ES6 mix-in ? I 've this pattern in library.js , and I 'd like to create the library.d.ts | // declaration in ` library.js ` class Super extends Simple { constructor ( ) { } static Compose ( Base = Super ) { return class extends Base { // ... } } } // usage in ` client.js ` class MyClass extends Super.Compose ( ) { } let myInstance = new MyClass ( ) ; class MyOtherClass extends Super.Compose ( AnotherClass ) ... | Typescript definition for ES6 mixins |
JS | I 'm trying to match usernames within a string like : The cases to match : substring is the first word trailing a space , in the middle surrounded by spaces or the last and leading a spaceFollowing characters are allowed to trail the word but not returned as a result : `` : ; , '' The following matches all the cases bu... | `` user : hi , has anyone seen user today user '' / ( ^ ( user ) [ \s| : | ; | , ] ) | ( \s ( user ) [ \s| : | ; | , ] ? \s ) | ( \s ( user ) ) /gi | Replacing usernames with links in Javascript with regular expressions |
JS | Why doesequals 4294967295 when equals 4294967296 ? Notice that the bitwise operation is one short . Why is this ? ! | ( ( 255 < < 24 ) | ( 255 < < 16 ) | ( 255 < < 8 ) |255 ) > > > 0 Math.pow ( 256,4 ) | 32 bit unsigned JavaScript bitwise operation is one short |
JS | According to this table in the ECMAScript standard , string values that have length 0 should be evaluated as boolean false.How come , then , these statements evaluate to true ? All those strings have a length greater than 0 . For example : While I understand that `` 0 '' evaluates to false because it can be coerced to ... | `` \t '' == false '' `` == false '' \n '' == false '' `` == false | Why do some non-empty strings evaluate to `` false '' in JavaScript ? |
JS | Can you explain how the JavaScript expression : parses/evaluates ? In Firefox , Chrome , Konqueror , and rhino , it seems to create an array with a single element , undefined . However , I do n't understand why . In Firefox : producesReplacing 1 with other JavaScript values seems to yield the same result.Update : I thi... | [ 1 [ { } ] ] [ 1 [ { } ] ] .toSource ( ) [ ( void 0 ) ] | How exactly does the JavaScript expression [ 1 [ { } ] ] parse ? |
JS | I have an array with student and parent addresses.For example , I 'm trying to reformat this to the following result.So far I tried the following way . I 'm not sure that is the right way or not . | const users = [ { id : 1 , name : 'John ' , email : 'johnson @ mail.com ' , age : 25 , parent_address : 'USA ' , relationship : 'mother ' } , { id : 1 , name : 'John ' , email : 'johnson @ mail.com ' , age : 25 , parent_address : 'Spain ' , relationship : 'father ' } , { id : 2 , name : 'Mark ' , email : 'mark @ mail.c... | JavaScript array re structure |
JS | I have a string for exampleI want to add a character to the beginning of every word such that the final string looks likeSo I did something like thisIs there any one liner to do this operation without creating an intermediary temp_array ? | some_string = `` Hello there ! How are you ? '' some_string = `` # 0Hello # 0there ! # 0How # 0are # 0you ? '' temp_array = [ ] some_string.split ( `` `` ) .forEach ( function ( item , index ) { temp_array.push ( `` # 0 '' + item ) } ) console.log ( temp_array.join ( `` `` ) ) | How to add a character to the beginning of every word in a string in javascript ? |
JS | I 'm trying to write a hubot script that answers to two different kinds of input . A user can either input the name of a stop for the local public transport or optionally postfix this with a delay.The input can therefore be dvb zellescher weg or dvb albertplatz for the first option or dvb zellescher weg in 5 or dvb alb... | robot.respond /^dvb ( \D* ) $ / , ( res ) - > hst = res.match [ 1 ] res.send hst | Coffeescript regex not matching as intended |
JS | Is it possible to render a zoomable charts and have it already zoomed . I 'm using a scatter plot which is zoomable on the x and y axis and would like to have it rendered already zoomed in to certain values . Is there any default zooming options I can set when defining the chart ? Here is a working example of the chart... | $ ( ' # container ' ) .highcharts ( { chart : { type : 'scatter ' , zoomType : 'xy ' } ... | HighCharts render chart already zoomed |
JS | I have a directive ct-steps-tooltip on an element along with ng-repeat like so : My goal was to get the directive to re-bind/get called again whenever currentItem.userData.steps changed ( I am actually completely clearing currentItem and then reassigning it ) . This actually works great in this simplified fiddle I made... | < div id='courseSteps ' class='relative ease { { step.action.toLowerCase ( ) } } ' ng-repeat='step in currentItem.userData.steps | filter : { action : filterSteps } track by $ index ' ng-class= ' { `` completed '' : step.endDate , `` pointer '' : step.action=== '' Submit '' & & ! step.endDate } ' ng-click='getRelated (... | Angular directive not being re-called with ng-repeat |
JS | I am trying to write a function that adds a class to all elements in a selection when those elements do not have that class yet , and vice versa : This gives an error that .classed is not a function . The documentation states that .classed should be called on a selection , so I tried changing the last line into ! d3.se... | function toggleLinksActivity ( d ) { d3.selectAll ( `` .link '' ) .filter ( l = > l.target == d ) .classed ( `` non-active '' , l = > ! l.classed ( `` non-active '' ) ) ; } function activateLinks ( d ) { d3.selectAll ( `` .link '' ) .filter ( l = > l.target == d ) .classed ( `` non-active '' , false ) ; } function deac... | How can I toggle the class of all elements in a selection ? |
JS | I 'm using JavaScript to create a basic graphic clock display on an HTML page . I 'm updating digit graphics ( each digit updated only when necessary ) using the standard DOM mechanism : The clock works fine , but I want to know whether all or some browsers will mindlessly fetch the image from my site every time the sr... | digitOne.src = `` file/path/one.png '' ; | Risk of constant traffic when updating graphics using JavaScript ? |
JS | I 've done according to angular mobile , https : //github.com/angular/mobile-toolkit/blob/master/guides/cli-setup.mdNode version v4.4.3NPM version 2.15.1Problem is when I type $ ng serve encounter following error . | Can not read property 'makeCurrent ' of undefinedTypeError : Can not read property 'makeCurrent ' of undefined at Object. < anonymous > ( /Users/user/Documents/Projects/PWA/hello-mobile/node_modules/angular2-universal/dist/node/node.js:7:35 ) at Module._compile ( module.js:409:26 ) at Object.Module._extensions..js ( mo... | Can not read property 'makeCurrent ' of undefined in angular mobile |
JS | Now in my records :14.3 , 14.2 and 14.1 belongs to part with Id =30.I am trying to achieve below:1 ) By default first 2 ids will be selected.Now if user try to select id = 71 which belongs to part 30 then user should not be allowed to select id=71 because higher version of part 30 is already selected i.e id=76.2 ) Now ... | var app = angular.module ( 'myApp ' , [ ] ) ; app.controller ( 'myCtrl ' , function ( $ scope ) { $ scope.myArray = [ { `` id '' : 77 , `` selected '' : true , `` part '' : 33 , `` name '' : `` 16.1 '' , } , { `` id '' : 76 , `` part '' : 30 , `` selected '' : true , `` name '' : `` 14.3 '' , } , { `` id '' : 71 , `` p... | Trying to manipulate array of object |
JS | I have some references in a React Native Web application - these references work on React Native , but not RNW.For example , I have this code : Which is based on this : Which is passed into a child component as a prop and used as such : It has several children ( who have nested children as well ) .However , on the web ... | this.highlight.current._children [ i ] .setNativeProps ( { style : { backgroundColor : `` black '' } } ) ; this.highlight.current._children [ i ] ._children [ 0 ] ._children [ 0 ] .setNativeProps ( { style : { color : `` white '' } } ) this.highlight.current._children [ i ] ._children [ 1 ] ._children [ 0 ] .setNativeP... | How do I access children components of a reference in React Native Web ? |
JS | I thought I had a pretty good understanding of async await until I tried this : After 15000ms , asyncTest is logging p1 & p2 . If instead promise1 and promise2 are transformed into functions that return these promises , execution time is then 25000ms . I have no idea what 's going on . Could anyone care to explain this... | const promise1 = new Promise ( ( resolve , reject ) = > { setTimeout ( ( ) = > resolve ( 'what ' ) , 10000 ) ; } ) ; const promise2 = new Promise ( ( resolve , reject ) = > { setTimeout ( ( ) = > resolve ( ' ? ' ) , 15000 ) ; } ) ; async function asyncTest ( ) { console.time ( ) ; const p1 = await promise1 ; if ( p1 ==... | Concurrent start with async/await |
JS | Mid development I decided to switch to server-side rendering for a better control amongst other benefits . My web application is completely AJAX based , no url redirecting , so the idea here is a website that builds itself upI just could n't figure out the proper way to send javascript events/functions along with the h... | $ ( `` body '' ) .on ( `` click '' , `` # open_table '' , function ( ) { $ .getJSON ( '/get_table ' , function ( response ) { $ ( `` # table_div '' ) .append ( response.html ) ; eval ( response.javascript ( ) ) ; // ? ? } } ) ; def get_table ( request ) : data = { } # String containing rendered html data [ 'html ' ] = ... | What 's the correct way to send Javascript code along with rendered HTTP to a client ? |
JS | Obviously you ca n't just surround the < tr > tag with an < a > tag and call it a day ; this is invalid and does n't even work . I have seen JavaScript used , but then what happens to browsers that do n't support JavaScript ? What is the best way to make an entire table row < tr > into a link ? Edit : At the request of... | < table > < thead > < tr > < th > Name < /th > < th > Number of widgets < /th > < /tr > < /thead > < tbody > < tr > < td > Bob Smith < /td > < td > Three < /td > < /tr > < tr > < td > Chuck Norris < /td > < td > Infinity+1 < /td > < /tr > < /tbody > < /table > | What is the most standard and compatible way to make a whole table row into a link ? |
JS | I 'm trying to provide functions in everyone 's pocket of nowjs . I 'd like to do so by _.extending everyone 's pocket , i.e . everyone.now . For some reason which I can not understand , _.extend fails to properly provide the function at the client side.This is my current code : On both the server and client sides , I ... | var _ = require ( `` underscore '' ) , everyone = require ( `` nowjs '' ) .initialize ( app ) ; everyone.now.foo = function ( ) { } ; _.extend ( everyone.now , { bar : function ( ) { } } ) ; console.log ( everyone.now.foo ) ; // [ Function ] console.log ( everyone.now.bar ) ; // undefined var proxy = Proxy.create ( { g... | Why ca n't I extend everyone 's pocket in nowjs ? |
JS | I 'm reading through the jQuery UI source code ( ui-dialog specifically ) , I see this pattern repeated many times : What 's the reasoning behind this pattern of , var self = this , something , something else | var self = this , options = self.options , uiDialog = self.uiDialog ; | jQuery UI Design Pattern Question |
JS | I have an array of objects , e.g . Let 's say I am only interested in objects whose keys correspond to var input = [ `` ab '' , `` bc '' ] . It means that I want to extract all possible subarrays with result [ i ] .length == 2 in the following way : — that is , the order of objects in subarrays is absolutely not import... | var arr = [ { `` a '' : `` x '' } , { `` b '' : `` 0 '' } , { `` c '' : `` k '' } , { `` a '' : `` nm '' } , { `` b '' : `` 765 '' } , { `` ab '' : `` i '' } , { `` bc '' : `` x '' } , { `` ab '' : `` 4 '' } , { `` abc '' : `` L '' } ] ; var result = [ [ { `` ab '' : `` i '' } , { `` bc '' : `` x '' } ] , [ { `` ab '' ... | How to extract all possible matching arrays of objects from one array of objects ? |
JS | I just saw a code snippet in MDN about destructuring rest parameters like so : the code snippet is in this page : https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parametersAlthough the common use case for rest parameters is very clear to me ( function foo ( ... params ) { /*code*/ } )... | function f ( ... [ a , b , c ] ) { return a + b + c ; } f ( 1 ) // NaN ( b and c are undefined ) f ( 1 , 2 , 3 ) // 6f ( 1 , 2 , 3 , 4 ) // 6 ( the fourth parameter is not destructured ) function f ( a , b , c ) { return a + b + c ; } f ( 1 ) // NaN ( b and c are undefined ) f ( 1 , 2 , 3 ) // 6f ( 1 , 2 , 3 , 4 ) // 6... | javascript es6 : use case for destructuring rest parameter |
JS | I 'm creating my own lightbox in React , and I have problem with implementation keyDown event . When I open image I want to have key a for image - 1 and d key for image + 1 . I only implemented console.log ( e.key ) to check if all works properly . And I found an issue , that my KeyDown event only works when I have foc... | < div onKeyDown= { this.nextButtonImage } onClick= { this.closeLightbox } className= '' lightbox-container '' > < div className= '' lightbox '' > < button onClick= { this.closeLightbox } className= '' lg-close '' > < i className= '' fas fa-times '' / > < /button > < button onClick= { this.prevImage } className= '' lg-a... | React - onKeyDown event |
JS | I 'm looking for a way to create variables dynamically in javascriptegI have a loop now I need to create variables dynamically eg var `` a '' +i for eavh value in the loop . Is this possible and how ? | for ( i=0 ; i < 15 ; i++ ) { } | How to create variables dynamiccally in JavaScript |
JS | Does the anonymous function in Foo get re-created in memory each time Foo ( ) gets called ? I 'm more or less interested in V8 's implementation in particular , since I 'm not seeing anything in regards to that in the spec ( unless I 'm missing something , which I probably am ) .I 'm kind of confused on the memory mana... | function Foo ( product ) { return function ( n ) { return n * product ; } } | Do nested function declarations create a new object each call ? |
JS | I 've been trying to create a html whack a mole game in which a mole has a class added to it at a certain interval , another timeout function is then triggered giving the user 3 seconds to click the mole and remove the class before a check is carried out which determines if that mole still has the class attached to it.... | var score = 0 ; var numberofpipes = 9 ; var lastnum = 0 ; var intervalseconds ; var interval ; var haslost = false ; var checkpipetimer ; var timeoutfunc ; var timeoutinit ; var timers = [ ] ; var burstingpipes = { } ; var timeoutinit = setTimeout ( startaburst , 3000 ) ; $ ( ' # scorecontainer ' ) .text ( score ) ; //... | Javascript settimeouts on html whack a mole game |
JS | I am measuring my website 's performance on the basis of performance object provided by HTML5 and I want to know that what is going wrong with my application , I also want to log these performance object of other end users in my local database so that I have information from theirs sides , but I am not quite familiar w... | var issueList = { 'connectStart ' : 'Network issue ' , 'connectEnd ' : 'Server is not responding fast with SSL handshake ' , 'domainLookupStart ' : 'Network issue ' , 'domainLookupEnd ' : 'Network issue ' , 'fetchStart ' : 'Slow browser ' , 'redirectStart ' : 'Network issue ' , 'redirectEnd ' : 'Busy server ' , 'reques... | Measuring JS Performance using HTML5 's performance and performance.timing object |
JS | I 'm having problems calling a server-side AppScript function from a html sidebar in Google Sheets.I 've replicated my issue with the simple example code below.What it should doClicking the button should call alert in my Code.gs script and display an alert to the user.What actually happensClicking the button shows the ... | We 're sorry , a server error occurred while reading from storage . Error code PERMISSION_DENIED . function onOpen ( ) { const ui = SpreadsheetApp.getUi ( ) ; ui.createMenu ( 'Matthew ' ) .addItem ( 'Show Sidebar ' , 'sidebar ' ) .addToUi ( ) ; } ; function sidebar ( ) { const html = HtmlService.createHtmlOutputFromFil... | Why ca n't I call a server function from the sidebar in Google AppScript for Sheets ? |
JS | I 'm poking around the Magento internals , and within the Widget/Tab rendering hierarchy there 's this concept of Shadow Tabs that I 'm a little fuzzy on . When you 're defining tabs for your form , you can bind it as a shadow tabThe bindShadowTabs method is documents withThe Javascript that leverages the PHP objects l... | protected function _prepareLayout ( ) { parent : :_prepareLayout ( ) ; $ this- > addTab ( 'bundle_items ' , array ( 'label ' = > Mage : :helper ( 'bundle ' ) - > __ ( 'Bundle Items ' ) , 'url ' = > $ this- > getUrl ( '*/*/bundles ' , array ( '_current ' = > true ) ) , 'class ' = > 'ajax ' , ) ) ; $ this- > bindShadowTa... | What are Shadow Tabs in Magento 's UI Object Hierarchy ? |
JS | I 've been looking for an efficient way to process large lists of vectors in javascript . I created a suite of performance tests that perform in-place scalar-vector multiplication using different data structures : AoS implementation : SoA implementation : The AoS implementation is at least 5 times faster . This caught ... | var vectors = [ ] ; //var vector ; for ( var i = 0 , li=vectors.length ; i < li ; ++i ) { vector = vectors [ i ] ; vector.x = 2 * vector.x ; vector.y = 2 * vector.y ; vector.z = 2 * vector.z ; } var x = new Float32Array ( N ) ; var y = new Float32Array ( N ) ; var z = new Float32Array ( N ) ; for ( var i = 0 , li=x.len... | Why does javascript process an array of structures faster than a structure of arrays ? |
JS | Let 's assume that we have the following function : I understand that data and type are just references to specific values in arguments . But why in the end , data is equal to 3 ? | var a = function ( data , type ) { var shift = [ ] .shift ; shift.call ( arguments ) ; shift.call ( arguments ) ; shift.call ( arguments ) ; shift.call ( arguments ) ; console.log ( data ) ; } a ( 1 , 'test ' , 2 , 3 ) ; | Javascript arguments shifting |
JS | I am trying to find the midpoint using duration traffic values ( n1 , n2 , n3 ) in specified departure time ( timeStamp ) so that all the three-person have the same travel time ( midpoint by Time ) . I 'm using Google distance matrix . I have been passing all three locations ( a , b , c ) & midpoint ( d ) based on the ... | const maxTime = 5000 ; var i = 0 ; z = 0 ; j = 0//Distance Matrix Apifunction getDistanceMatrix ( a , b , c , d , timeStamp , googleWarnings , copyRights ) { clientMap.post ( config_KEYS.DISTANCE_MATRIX_API + a + `` | '' + b + `` | '' + c + `` & destinations= '' + d.lat + `` , '' + d.lng + `` + & key= '' + config_KEYS.... | I am trying to find mid point with duration traffic ( based on traffic with respect to departure time ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.