134 thoughts on “javascript”

  1. Professional JavaScript for Web Developers [4th edition]

    Node.js Design Patterns [3rd edition]

    Distributed Systems with Node.js

    Implementing DDD, CQRS, and Event Sourcing

    Multithreaded JavaScript: Concurrency Beyond the Event Loop

  2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

    Instead of if else if , there’s a ternary operator

    condition ? exprIfTrue : exprIfFalse

    Copied and pasted–>

    function getFee(isMember) {
    return (isMember ? ‘$2.00’ : ‘$10.00’);
    }

    console.log(getFee(true));
    // expected output: “$2.00”

    console.log(getFee(false));
    // expected output: “$10.00”

    console.log(getFee(null));
    // expected output: “$10.00”

    “The ternary operator is right-associative, which means it can be “chained” in the following way, similar to an if … else if … else if … else chain:

    function example(…) {
    return condition1 ? value1
    : condition2 ? value2
    : condition3 ? value3
    : value4;
    }

    // Equivalent to:

    function example(…) {
    if (condition1) { return value1; }
    else if (condition2) { return value2; }
    else if (condition3) { return value3; }
    else { return value4; }
    }

  3. What the heck are workers?

    Apparently they have access to a lot of APIs but not the SAME global scope.

    You basically put them in a corner with their own code and they work the synchronous task without gumming up your browser.

    They can send messages and let you know when they have data or other results for you.

    https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API


    References
    Web Workers API

    Web Workers concepts and usage
    A worker is an object created using a constructor (e.g. Worker()) that runs a named JavaScript file — this file contains the code that will run in the worker thread.

    In addition to the standard JavaScript set of functions (such as String, Array, Object, JSON, etc.), you can run almost any code you like inside a worker thread. There are some exceptions: for example, you can’t directly manipulate the DOM from inside a worker, or use some default methods and properties of the window object. For information about the code that you can run see worker global context and functions, and supported web APIs below.

    Data is sent between workers and the main thread via a system of messages — both sides send their messages using the postMessage() method, and respond to messages via the onmessage event handler (the message is contained within the Message event’s data property). The data is copied rather than shared.

    Workers may in turn spawn new workers, as long as those workers are hosted within the same origin as the parent page. In addition, workers may use XMLHttpRequest for network I/O, with the exception that the responseXML and channel attributes on XMLHttpRequest always return null.

    Worker types
    There are a number of different types of workers:

    Dedicated workers are workers that are utilized by a single script. This context is represented by a DedicatedWorkerGlobalScope object.
    Shared workers are workers that can be utilized by multiple scripts running in different windows, IFrames, etc., as long as they are in the same domain as the worker. They are a little more complex than dedicated workers — scripts must communicate via an active port.
    Service Workers essentially act as proxy servers that sit between web applications, the browser, and the network (when available). They are intended, among other things, to enable the creation of effective offline experiences, intercept network requests and take appropriate action based on whether the network is available, and update assets residing on the server. They will also allow access to push notifications and background sync APIs.
    Note: As per the Web workers Spec, worker error events should not bubble (see bug 1188141. This has been implemented in Firefox 42.

    Worker global contexts and functions
    Workers run in a different global context than the current window! While Window is not directly available to workers, many of the same methods are defined in a shared mixin (WindowOrWorkerGlobalScope), and made available to workers through their own WorkerGlobalScope-derived contexts:

    DedicatedWorkerGlobalScope for dedicated workers
    SharedWorkerGlobalScope for shared workers
    ServiceWorkerGlobalScope for service workers
    Some of the functions (a subset) that are common to all workers and to the main thread (from WindowOrWorkerGlobalScope) are: atob(), btoa(), clearInterval(), clearTimeout(),dump() , setInterval(), setTimeout().

    The following functions are only available to workers:

    WorkerGlobalScope.importScripts() (all workers),
    DedicatedWorkerGlobalScope.postMessage (dedicated workers only).
    Supported Web APIs
    Note: If a listed API is supported by a platform in a particular version, then it can generally be assumed to be available in web workers. You can also test support for a particular object/function using the site: https://worker-playground.glitch.me/

    The following Web APIs are available to workers: Barcode Detection API, Broadcast Channel API, Cache API, Channel Messaging API,Console API, Web Crypto API (Crypto), CustomEvent, Data Store (Firefox only), DOMRequest and DOMCursor, Encoding API (TextEncoder, TextDecoder, etc.), Fetch API, FileReader, FileReaderSync (only works in workers!), FormData, ImageData, IndexedDB, Network Information API, Notifications API, Performance API (including: Performance, PerformanceEntry, PerformanceMeasure, PerformanceMark, PerformanceObserver, PerformanceResourceTiming), Promise, Server-sent events, ServiceWorkerRegistration, URL API (e.g. URL), WebGL with OffscreenCanvas (enabled behind a feature preference setting gfx.offscreencanvas.enabled), WebSocket, XMLHttpRequest.

    Workers can also spawn other workers, so these APIs are also available: Worker, WorkerGlobalScope, WorkerLocation, WorkerNavigator.

    1. The following Web APIs are available to workers: Barcode Detection API, Broadcast Channel API, Cache API, Channel Messaging API,Console API, Web Crypto API (Crypto), CustomEvent, Data Store (Firefox only), DOMRequest and DOMCursor, Encoding API (TextEncoder, TextDecoder, etc.), Fetch API, FileReader, FileReaderSync (only works in workers!), FormData, ImageData, IndexedDB, Network Information API, Notifications API, Performance API (including: Performance, PerformanceEntry, PerformanceMeasure, PerformanceMark, PerformanceObserver, PerformanceResourceTiming), Promise, Server-sent events, ServiceWorkerRegistration, URL API (e.g. URL), WebGL with OffscreenCanvas (enabled behind a feature preference setting gfx.offscreencanvas.enabled), WebSocket, XMLHttpRequest.

      Workers can also spawn other workers, so these APIs are also available: Worker, WorkerGlobalScope, WorkerLocation, WorkerNavigator.

  4. MYSQL API for js… From the horse’s mouth

    De

    https://dev.mysql.com/doc/dev/mysqlsh-api-javascript/8.0/

    MySQL Shell API 8.0.29
    Unified development interface for MySQL Products

    MySQL Shell API
    This document covers the JavaScript APIs available in the MySQL Shell:

    (1) X DevAPI – NoSQL Database API for MySQL and the MySQL Document Store.

    (2) ShellAPI – Shell API and backward compatibility API for MySQL Servers not supporting the X DevAPI.

    (3) AdminAPI – API for setting up and managing InnoDB Clusters, InnoDB ReplicaSets, and InnoDB ClusterSets.

    The functionality of the APIs is exposed through modules and global objects which are automatically available when the MySQL Shell starts.

    1. According to this website, shiny server only comes with Linux (Ubuntu, red hat, or CentOS

      http://rstudio.github.io/shiny-server/os/0.4.0/

      Shiny Server is currently only supported on the Linux operating system. We officially support the following distributions:

      RedHat Enterprise Linux (and CentOS) 5.4+
      RedHat Enterprise Linux (and CentOS) 6.0+
      Ubuntu 12.04
      Ubuntu 13.04
      We currently only support the x86-64 architecture. As described in the Installation section, you will install R and the Shiny package prior to installing Shiny Server. Root privileges will be required both in the installation process and also at runtime.

Leave a comment