Skip to content

Instantly share code, notes, and snippets.

@fobiasmog
Last active March 23, 2023 11:26

Revisions

  1. fobiasmog revised this gist Mar 23, 2023. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions js_notes.md
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,9 @@ Get element by XPath
    function getElementByXpath(path) {
    return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    }
    ```

    Random value on range
    ```js
    Math.floor(Math.random() * (max - min) + min)
    ```
  2. fobiasmog revised this gist Nov 23, 2022. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions js_notes.md
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,11 @@ function getResponseErrors(errors) {

    return flatMapDeep(errors, deep);
    }
    ```

    Get element by XPath
    ```js
    function getElementByXpath(path) {
    return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    }
    ```
  3. fobiasmog revised this gist Apr 15, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions js_notes.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    Рекурсивное получение массива значений в хэше/дереве
    ```js
    import flatMapDeep from 'lodash/flatMapDeep'

    function getResponseErrors(errors) {

    function deep(n) {
  4. fobiasmog revised this gist Apr 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion js_notes.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ```
    ```js
    function getResponseErrors(errors) {

    function deep(n) {
  5. fobiasmog renamed this gist Apr 15, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. fobiasmog created this gist Apr 15, 2021.
    11 changes: 11 additions & 0 deletions Заметки по JS
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ```
    function getResponseErrors(errors) {

    function deep(n) {
    if (typeof(n) === 'object') return flatMapDeep(n, deep);
    return n;
    }

    return flatMapDeep(errors, deep);
    }
    ```